VBC00043 — Next without For
Severity: Error · Family: VBC (parser / concrete syntax tree) ·
Source metadata: VBSyntaxErrorInfo
A Next statement ends no For loop.
A Next statement ends the For or For Each loop it is written in. Where none is open - or where the block open is another one, an If or a With that is not closed yet - there is no loop for it to end.
MS-VBA reports the same error, with the same message (recorded in Excel).
This code is raised by the parser, at the statement that does not fit, when the grammar refuses a procedure whose blocks do not match. RD-VBA reports it for every procedure; MS-VBA stops at the first.
How it is raised
| Situation | Example | Resolution |
|---|---|---|
A Next with no loop. |
Next alone in a procedure |
Remove it, or write the For statement it ends. |
A Next inside a block that is not closed. |
For i = 1 To 2 … If x Then … Next |
Close the inner block first: End If before Next. |
See also
⏮️ VBC00042 Numeric literal overflow | ⏭️ VBC00044 For without Next
ACCUEIL • HOME | ℹ️ BIENVENUE • WELCOME | 🧩 BÂTISSONS • BUILD | RD-VBAL | SDK | 🌐 rubberduckvba.ca