Table of Contents

VBC00056: An #ElseIf, #Else, or #EndIf must be preceded by an #If clause

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

A #End If directive ends no #If block.

There is no #If before it, or the #If before it is not a directive. An #If is a directive when it is written #If expression Then, with nothing after Then but a comment. An #If with no Then, one whose expression is no expression, one with code after its Then, and a keyword that is not If (#Iff) are no directives, and open no block. Each is a syntax error of its own too (VBC00001), at the token that is not what the directive's rule expects.

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

This code is raised by the parser, at the #End If.

How it is raised

Situation Example Resolution
An #End If with no #If. Private Const A = 1 … #End If Remove the #End If, or write the #If it ends.
An #If with no Then. #If VBA7 … #End If Write #If VBA7 Then.
Code after Then. #If VBA7 Then Private Const A = 1 … #End If Write the code on the lines after the #If.
An expression that is incomplete. #If X = Then … #End If Complete the expression.

See also


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