Skip to content

VBA180 — Statement invalid inside Enum block

Severity: 🔴 error Category: placement Phase: 3.7

Description

An Enum … End Enum block may only contain member declarations (Name [= value]). Executable statements or Dim/Sub/… declarations inside it are illegal.

Failing example

Enum E
    A = 1
    Dim x As Long
End Enum

Compliant example

Enum E
    A = 1
    B = 2
End Enum

How to fix

Move the statement outside the Enum; keep only Name = value members inside.


Source: src/rules.py — entry VBA180.