The Counter variable and the Variable Following Next Must be the Same Error

In a For loop, if you use both a counter variable and a variable in the Next statement, they must match. The variable on the Next statement can be omitted.


Example

In the following For loop, the counter variable is i, so the variable on the Next statement must also be i

Dim i,j as Integer
For i=1 to 10
 j=j+1
Next j

.


See Also

For statement.