For loop with defined increment of the downward counting running variable

The loop requires a running variable. In the example below, the run variable i is initialized with a value of 100 and decreased by 2 each time the End For is reached. If the cancellation condition is 0, 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 := 1000 DownTo 0 Step 2

   k += 100

   Exit For If k >= 1000

End For