For...Next

This statement repeats a group of statements a specified number of times.

Syntax

For counter = start To end [Step step]
[statements]
[Exit For]
[statements]
Next [counter]

Parameters

counter
Numeric variable used as a loop counter. The variable cannot be an array element or an element of a user-defined type.
start
Initial value of counter.
end
Final value of counter.
step
Amount counter is changed each time through the loop. If you do not specify the amount, step defaults to one.
statements
One or more statements between For and Next that are executed a specified number of times.

Remarks

The step parameter can be either positive or negative. The following table shows how the value of the step parameter determines loop processing.

Value
Loop executes if
Positive or 0 counter <= end
Negative counter >= end