-
Solved: I'm not understanding why these loops are working in the opposite direction
Edited and swapped the loop result descriptions twice
I'm confused and need more rest I guess. Or more coffee
What is different in these two loops?
this loop reports as I would expect (from Cell A1 to the last row in Col A)
[vba]For Each aCell In Range("A1:A" & Range("A" & Rows.Count).End(xlUp).Row - 1)
MsgBox aCell.Row
Next[/vba]
Why is this looping technique reporting the last row number first
[vba]For X = 0 To Range("A" & Rows.Count).End(xlUp).Row - 1
MsgBox X
Next
[/vba]
Last edited by frank_m; 03-06-2011 at 07:57 PM.
-
Another Correction to my comments: Both loops are starting from the last row and working their way up.
What am I not realizing ?
-
Greetings Frank,
With data down to (inclusive) A28, they both loop from low to high, ending at 27, due to .Row - 1.
Mark
-
Hi Mark,
Thanks for testing it, rather than just reporting to me that I'm crazy.
I had declining cell values that I was confusing with row numbers. -- That combined with not not enough sleep
-
Trust me, I am most empathetic. I've been on graves for the past year; words for which I could not use here...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules