+ Reply to Thread
Results 1 to 13 of 13

loop past blank cell

  1. #1
    Registered User
    Join Date
    11-22-2006
    Posts
    80

    loop past blank cell

    I have a range A2:A30 and in this range a blank cell may exist.

    I am capturing the last used cells value of this range, but need to get past this blank cell. I need to keep the previous cell value and move past the blank cell.
    Last edited by Zrx; 10-20-2011 at 12:45 PM. Reason: solved

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: loop past blank cell

    Hi Zrx, you aren't really giving us much to go on. Are you looping through the range? What is supposed to happen to the cells that aren't empty?
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  3. #3
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: loop past blank cell

    Something like....

    =LOOKUP(9.99999999999999E+307,A:A)

    http://www.xldynamic.com/source/xld.LastValue.html
    HTH
    Regards, Jeff

  4. #4
    Registered User
    Join Date
    11-22-2006
    Posts
    80

    Re: loop past blank cell

    Quote Originally Posted by Mordred View Post
    Hi Zrx, you aren't really giving us much to go on. Are you looping through the range? What is supposed to happen to the cells that aren't empty?
    Looping through range to find last value and "trapping" this to varible (completed) but when I encounter a blank cell it will use the previous cell as it is the last cell value so the loop thinks.


    Please Login or Register  to view this content.
    I am looking into the xlup instead but running into issues.
    Last edited by Zrx; 10-16-2011 at 04:55 PM. Reason: add code tags

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,509

    Re: loop past blank cell

    Please use CODE Tags around your code excerpt.

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: loop past blank cell

    Hi Zrx
    Don't pretend to know what you're trying to do.

    To find the last populated cell in Column C
    Please Login or Register  to view this content.
    To find the next unpopulated cell in Column C
    Please Login or Register  to view this content.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  7. #7
    Registered User
    Join Date
    11-22-2006
    Posts
    80

    Re: loop past blank cell

    Try again to explain...

    Range = A2:A33

    Cells will have numbers but some cells may be blank. I use the last cell value to subtract a new number from. The issue is when you get a cell in between which is blank the code will take that number above it even if there is non blank cells below.

    Not the best explaination I guess

  8. #8
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: loop past blank cell

    Hi Zrx

    Perhaps an example file coupled with an explanation ?

  9. #9
    Registered User
    Join Date
    11-22-2006
    Posts
    80

    Re: loop past blank cell

    Ok, using vba. Find last cell with data (always number). This cell will be subtracted from another. If you look at sample you see yellow cell my current vba stops here as it is last cell, above cell actually. I need a code piece to get past these blank cells but keeping the above cells value so it may be subtracted. This should be a place to start.
    Attached Files Attached Files
    Last edited by Zrx; 10-17-2011 at 08:07 PM. Reason: try to explain again

  10. #10
    Registered User
    Join Date
    11-22-2006
    Posts
    80

    Re: loop past blank cell

    Progress I believe.....

    Please Login or Register  to view this content.

    Now, I'm working on getting the code to back up one cell (above yellow) cell and "trap" cell value for use else where. This is the next step.

  11. #11
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: loop past blank cell

    Hi Zrx

    I don't know...based on your sample file...try this
    Please Login or Register  to view this content.
    Last edited by jaslake; 10-17-2011 at 11:44 PM.

  12. #12
    Registered User
    Join Date
    11-22-2006
    Posts
    80

    Re: loop past blank cell

    Quote Originally Posted by jaslake View Post
    Hi Zrx

    I don't know...based on your sample file...try this
    Please Login or Register  to view this content.
    Yes this finsihed code is working fine, but I see now I need to shift my approach. I need to work across the row instead of the colum. So I have the offset working but fail to get test conditons to work. Can you "nest" trying to below? OR is another approach better.


    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    11-22-2006
    Posts
    80

    Re: loop past blank cell

    Please Login or Register  to view this content.
    looks like I finally have it. This is achieving what I wish. I do need to tweak the second set of offsets.

    If anyone can see ways to improve I'm all ears.

+ 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