Table of Contents

RDC11034: Name that MS-VBA refuses

Severity: Warning  ·  Family: RDC (Rubberduck Core analyzers)  ·  Raised by: DeclarationNameDivergenceAnalyzer

A declaration has a name that the specification allows, and MS-VBA refuses.

A declaration is named with an identifier that is not a reserved identifier (MS-VBAL §3.3.5.2 Reserved Identifiers and IDENTIFIER). A member of a user-defined type can also be named with a reserved name (MS-VBAL §5.2.3.3 User Defined Type Declarations). MS-VBA refuses names the specification allows (observed in Excel):

  • a reserved type identifier that is not a reserved name (Boolean, Byte, Currency, Double, Integer, Long, LongLong, LongPtr, Single, Variant), as the name of anything but a member of a user-defined type;
  • Local, which is not a reserved identifier, as the name of anything but a member of a user-defined type;
  • Me, which is a reserved name, as the name of a member of a user-defined type;
  • Name, which is not a reserved identifier, as the name of an Enum member.

Code exported from MS-VBA never has these names, so RD-VBA keeps to the specification: the declaration compiles, and this warning says that MS-VBA would not compile the module.

How it is raised

Situation Example Resolution
A variable, a constant, a parameter, a procedure or an Enum member named with a reserved type identifier, such as Long or Integer. Dim Long As Long Give it another name, such as Count.
A variable, a constant, a parameter, a procedure or an Enum member named Local. Dim Local As Long Give it another name, such as LocalValue.
A member of a user-defined type named Me. Private Type Node ... Me As Long ... End Type Give the member another name, such as Self.
An Enum member named Name. Private Enum Column ... Name ... End Enum Give the member another name, such as NameColumn.

A name written in brackets ([Long]) is a foreign name (MS-VBAL §3.3.5.3), and is not reported.

See also


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