Home |
Search |
Today's Posts |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here's an example where the loop counter is set outside the range. The
"For" loop code still needs to run its test. 5.5 is incremented by 1 to 6.5. The test now fails, and the code continues... Sub Demo() Dim j For j = 1 To 3 Debug.Print j j = 5.5 Debug.Print j Next j Debug.Print j End Sub 1 5.5 6.5 -- Dana DeLouis Win XP & Office 2003 "GreenInIowa" wrote in message ... Hi, I have the following simple loop where I want "i' to go from 1 to 3. Sub test() For i = 1 To 3 Debug.Print "Inside of the loop"; i Next Debug.Print "Outside of the loop"; i End Sub ==Out put is == Inside of the loop 1 Inside of the loop 2 Inside of the loop 3 Outside of the loop 4 It does what I expect inside the loop. But, as soon as loop is completed its value increases by one to 4 although I see no reason for this. Why? Anybody has any answer for this? Thanks. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
For Each - loop doesn't work. | Excel Programming | |||
Excel Visual Basic - need help to create a loop of filenames | Excel Programming | |||
Excel formula similar to a loop in Basic? | Excel Worksheet Functions | |||
Would a loop work? | Excel Programming | |||
Why doesn't my loop work? | Excel Programming |