Table of Contents

VBC00058: An #ElseIf must be preceded by an #If or #ElseIf and followed by an #Else or #EndIf

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

A #ElseIf directive belongs to no #If block, or comes after the #Else of its block.

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

This code is raised by the parser, at the #ElseIf.

How it is raised

Situation Example Resolution
An #ElseIf with no #If. Private Const A = 1 … #ElseIf VBA7 Then Write the #If the #ElseIf belongs to, or make it an #If.
An #ElseIf after the #Else. #If Mac Then … #Else … #ElseIf VBA7 Then … #End If Move the #ElseIf before the #Else.

See also


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