+ Reply to Thread
Results 1 to 7 of 7

For each....that is not blank

  1. #1
    Aria
    Guest

    For each....that is not blank

    Hello,
    How do you change this line to become For Each c in the range of B2 to
    B12 that is Not Blank?

    For Each c In Sheets("Inventory").Range("B2:B12")

    Aria

    *** Sent via Developersdex http://www.developersdex.com ***

  2. #2
    Valued Forum Contributor Excelenator's Avatar
    Join Date
    07-25-2006
    Location
    Wantagh, NY
    Posts
    333
    Please Login or Register  to view this content.
    ---------------------------------------------------
    ONLY APPLIES TO VBA RESPONSES WHERE APPROPRIATE
    To insert code into the VBE (Visual Basic Editor)
    1. Copy the code.
    2. Open workbook to paste code into.
    3. Right click any worksheet tab, select View Code
    4. VBE (Visual Basic Editor) opens to that sheets object
    5. You may change to another sheets object or the This Workbook object by double clicking it in the Project window
    6. In the blank space below the word "General" paste the copied code.

  3. #3
    Dave Peterson
    Guest

    Re: For each....that is not blank

    How about just ignore the blanks, but still loop through them:

    for each c in sheets("inventory").range("B2:B12").cells
    if c.value = "" then
    'do nothing, skip it
    else
    'do the real work here
    end if
    next c


    Aria wrote:
    >
    > Hello,
    > How do you change this line to become For Each c in the range of B2 to
    > B12 that is Not Blank?
    >
    > For Each c In Sheets("Inventory").Range("B2:B12")
    >
    > Aria
    >
    > *** Sent via Developersdex http://www.developersdex.com ***


    --

    Dave Peterson

  4. #4
    Bernie Deitrick
    Guest

    Re: For each....that is not blank

    If you know that they are constants (but not "" - those aren't actually blank), you could use:
    For Each c In Sheets("Inventory").Range("B2:B12").SpecialCells(xlCellTypeConstants,23)

    Or if they are all formulas (but not formulas that return "" - those also aren't actually blank):
    For Each c In Sheets("Inventory").Range("B2:B12").SpecialCells(xlCellTypeFormulas,23)

    HTH,
    Bernie
    MS Excel MVP


    <Aria> wrote in message news:[email protected]...
    > Hello,
    > How do you change this line to become For Each c in the range of B2 to
    > B12 that is Not Blank?
    >
    > For Each c In Sheets("Inventory").Range("B2:B12")
    >
    > Aria
    >
    > *** Sent via Developersdex http://www.developersdex.com ***




  5. #5
    Aria
    Guest

    Re: For each....that is not blank

    Thanks Excelenator, that's exactly what I needed. Thanks to Dave also.
    How do you set another condition that for each d in C2 to C12 that
    matches to $A$1, then afterwards trigger this code?

    For Each c In Sheets("Inventory").Range("B2:B12")
    If c.value <> "" Then
    -your code here-
    End if
    Next c

    Aria


    *** Sent via Developersdex http://www.developersdex.com ***

  6. #6
    Valued Forum Contributor Excelenator's Avatar
    Join Date
    07-25-2006
    Location
    Wantagh, NY
    Posts
    333
    Something like this???


    Please Login or Register  to view this content.

  7. #7
    Aria
    Guest

    Re: For each....that is not blank

    Yes, thank-you Excelenator! That's exactly what I needed.
    Aria



    *** Sent via Developersdex http://www.developersdex.com ***

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1