+ Reply to Thread
Results 1 to 6 of 6

run a loop from bottom - up?

  1. #1
    Forum Contributor
    Join Date
    05-09-2009
    Location
    Chicago, US
    MS-Off Ver
    Excel 2003, Excel 2007
    Posts
    188

    run a loop from bottom - up?

    Hi all, by definition loops fun from the first row and down. I have a set of data that i need to run a loop from the bottom (5000th row) to the top (2nd row).

    here is the sample loop that would work if i needed 2nd row to 5000th.

    Please Login or Register  to view this content.
    so what would i change in this loop for it to run in reverse? from the very bottom to the very top (2nd row)?


    ps. does it matter that cell is in all small caps? when i type Cells, it automatically makes it small cap. does that matter at all?

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: run a loop from bottom - up?

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor
    Join Date
    05-09-2009
    Location
    Chicago, US
    MS-Off Ver
    Excel 2003, Excel 2007
    Posts
    188

    Re: run a loop from bottom - up?

    Thank you. That does work!

    How would I do it if I didn't know how many rows there were? If it always changes? Here is what I am trying to do, even though I do not understand why I would use .End(xlUp) instead of .End(xlDown) ? Can someone please explain this? I know I am using the correct one, but what does .End(xlUp) do after the Rows.Count statement? Doesn't it just return the value all the way to the top of the column?

    Anyway, here is what I have and it isn't working:

    Please Login or Register  to view this content.

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,625

    Re: run a loop from bottom - up?

    Please Login or Register  to view this content.
    The & concatenates the two strings. For instance, If LR had returned 3098, then "H2" & LR would create the string: H23098; the above will create: H2:H3098
    Ben Van Johnson

  5. #5
    Forum Contributor
    Join Date
    05-09-2009
    Location
    Chicago, US
    MS-Off Ver
    Excel 2003, Excel 2007
    Posts
    188

    Re: run a loop from bottom - up?

    So if I find the last row with LR, do I still need to use the

    Please Login or Register  to view this content.
    Or is there a way for me to code it something like,

    Please Login or Register  to view this content.
    would that be correct as well?

  6. #6
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,625

    Re: run a loop from bottom - up?

    Yes, it would
    Also,
    Cells(Rows.Count, "H") goes to the bottom of column H i.e., H65536
    End(xlUp) does the same as ctrl + up arrow, i.e. moves up the the first used cell
    .Row returns the row number
    Last edited by protonLeah; 02-12-2010 at 10:58 PM.

+ 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