Delen via


'Next' statement names more variables than there are matching 'For' statements

Nested loops are terminated with a single Next statement that specifies more loop variables than there are loops in the nest, as in the following example:

For I = 1 To 10
   For J = 1 To 5
      ' ...
Next J, I, K   ' Next J, I is valid, but there is no loop on K.

Error ID: BC32037

To correct this error

  1. Ensure that the Next statement specifies all the nested loop variables in the reverse order of loop initiation.

  2. Remove any extraneous variables from the Next statement.

See Also

Reference

For...Next Statement (Visual Basic)