Microsoft KB Archive/120800

= Microsoft Knowledge Base =

XL: Incorrect Error Message: "For Without Next"
Last reviewed: September 13, 1996

Article ID: Q120800

The information in this article applies to:


 * Microsoft Excel for Windows, version 5.0, 5.0c
 * Microsoft Excel for Windows 95, version 7.0
 * Microsoft Excel for the Macintosh, version 5.0

SUMMARY
In Microsoft Excel for Windows versions 5.x and 7.0, you may receive the following error message

For Without Next even when you do have the Next statement that concludes a For loop.

MORE INFORMATION
The "For Without Next" error message is generated if Visual Basic, Applications Edition, detects that a For loop has been started but the Next statement is not present to end the loop. It is also generated erroneously if you have an End If statement within the For-Next loop.

Steps to Reproduce Problem
Enter the following on a module sheet:

Sub Test For X = 1 To 2 End If     Next End Sub If you try to run this code, you get the following error message:

For without Next The proper error message should be:

End If without Block If