Table of Contents

VBC09359 — Invalid Next control variable reference

Severity: Error  ·  Family: VBC (static semantics / abstract syntax tree)  ·  Source metadata: VBCompileErrorInfo

A Next statement names a variable that is not the control variable of its loop.

The variable a Next statement names, if it names one, is the control variable of the For loop it ends.

MS-VBA reports the same error, with the same message (recorded in Excel).

This code is raised by StatementStaticSemanticsEvaluator.

How it is raised

Situation Example Resolution
A Next that names another variable. For i = 1 To 2 … Next j Name the loop's own variable, or none: Next.

See also


⏮️ VBC09358 For control variable already in use | ⏭️ VBC09360 Can't assign to array


ACCUEIL • HOME | ℹ️ BIENVENUE • WELCOME | 🧩 BÂTISSONS • BUILD | RD-VBAL | SDK | 🌐 rubberduckvba.ca