For loop with defined increment of the upward-counting running variable

The loop requires a running variable. In the example below, the run variable i is initialized with a value of 0 and incremented by 2 each time the End For is reached. When the cancellation condition 100 is reached, the code continues after the End For.

The loop can be aborted prematurely with the Exit For command.

The loop can be continued with the Continue command at the next index.

 

Dim i As Long, k As Long

 

For i := 0 To 100 Step 2

   k += 100

   Exit For If k >= 1000

End For