Invalid Next control variable reference
Last modified: December 06, 2011
Applies to: Office 2013 | VBA
The numeric variable in the Next part of a For...Next loop must match the variable in the For part. This error has the following cause and solution:
The variable in the Next part of a For...Next loop differs from the variable in the For part. For example:
For Counter = 1 To 10 MyVar = Counter Next Count
Check the spelling of the variable in the Next part to be sure it matches the For part. Also, be sure you haven't inadvertently deleted parts of the enclosing loop that used the variable.
For additional information, select the item in question and press F1 (in Windows) or HELP (on the Macintosh).