rjwebgraphix
Well-known Member
- Joined
- May 25, 2010
- Messages
- 590
Somehow all my for loops are now broken and I don't know how it happened. It's like XL is just ignoring it. If anyone has any clue why this is happening, please let me know.
Example: The following code as two loops, a for loop and a do loop. In theory both loops do exactly the same thing. In cells A2-A16 is merely the letter A thru P respectively just to keep it simple for this test. You would expect it would give me 32 subsequent msgboxes giving me the value of each cell, but it completely ignores the For loop and runs the Do loop as it should giving me only 16 message boxes starting at cell A16 (Value P) ending at cell A2 (Value A)
I don't see anything with the code that would cause it to not work, so it has to be something with XL causing it. It's a company load laptop, so it's not like I can uninstall and reinstall, I'd have to send it out of state for them to reload it and I'd rather avoid that if possible. Thanks for any input on this.
Example: The following code as two loops, a for loop and a do loop. In theory both loops do exactly the same thing. In cells A2-A16 is merely the letter A thru P respectively just to keep it simple for this test. You would expect it would give me 32 subsequent msgboxes giving me the value of each cell, but it completely ignores the For loop and runs the Do loop as it should giving me only 16 message boxes starting at cell A16 (Value P) ending at cell A2 (Value A)
I don't see anything with the code that would cause it to not work, so it has to be something with XL causing it. It's a company load laptop, so it's not like I can uninstall and reinstall, I'd have to send it out of state for them to reload it and I'd rather avoid that if possible. Thanks for any input on this.
Code:
Sub Testit2()
Dim i As Long
Dim r As Long
For i = 16 To 2
MsgBox Cells(i, "A").Value & " For Loop"
Next i
r = 16
Do While r <> 1
MsgBox Cells(r, "A").Value & " Do Loop"
r = r - 1
Loop
End Sub