+ Reply to Thread
Results 1 to 3 of 3

How to loop till last row with data?

  1. #1
    Registered User
    Join Date
    02-20-2012
    Location
    Chicago, Illinois
    MS-Off Ver
    Excel 2010
    Posts
    25

    How to loop till last row with data?

    Hello to my forum friends!

    I have a worksheet of data that I need to parse. Got a pretty extensive macro script already running, but I'm still kinda' new to scripting in Excel VBA.

    My worksheet looks like this:

    =====
    known-starting-point - row of data
    row of data
    row of data
    [empty row (cells w/formulas & formatting but no values)]
    row of data
    row of data
    [empty row (cells w/formulas & formatting but no values)]
    row of data
    [empty row (cells w/formulas & formatting but no values)]
    last row of data
    =====

    I'll just be reading the data, not modifying or deleting. I have no way of knowing ahead of time which rows will be "empty", so I have to determine that, and skip to the next row.

    I need to loop through all the rows from the known-starting-point to the last row that contains values. "Empty" rows that I want to skip may contain formulas (no values) and cell formatting. Something like this pseudo-code:

    Please Login or Register  to view this content.
    Thanks in advance for pointing me in the right direction!

    BTM
    Last edited by btmtdk; 03-19-2012 at 10:35 AM. Reason: Flag as Resolved

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,164

    Re: How to loop till last row with data?

    Hi,

    I use in my code

    LastRow = Cells(Rows.Count,"A").End(xlUp).Row

    See if that doesn't do it for you. Rows.Count is the last row in a worksheet. The End(xlUp) is like doing a Ctrl-Up manually.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    02-20-2012
    Location
    Chicago, Illinois
    MS-Off Ver
    Excel 2010
    Posts
    25

    Re: How to loop till last row with data?

    Thank you Marvin! That did the trick for me.

    Have a great week....

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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