Table of Contents

VBC00054 — Invalid outside procedure

Severity: Error  ·  Family: VBC (parser / concrete syntax tree)  ·  Source metadata: VBSyntaxErrorInfo

A statement that runs is written in the declarations section of a module.

The declarations section of a module - before its first procedure - is made of declarations: Option statements, variables, constants, types, enumerations, Declare statements. A statement that runs belongs in a procedure.

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

This code is raised by the parser, at the first statement of each stretch that does not belong there, when the grammar refuses the module.

How it is raised

Situation Example Resolution
A statement before the first procedure. Debug.Print 1 at the top of a module Move it into a procedure.
An assignment before the first procedure. q = 1 at the top of a module Declare q there, and assign it in a procedure.

See also


⏮️ VBC00053 Expected End With | ⏭️ VBC00055 Only comments may appear after End Sub, End Function, or End Property


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