ElseIf must be preceded by a matching If or ElseIf and followed by an ElseIf, Else, or EndIf
ElseIf is a conditional compilation directive. This error has the following causes and solutions:
An
#elseif
has been detected that isn't preceded by an#if
or#elseif
. Place an#if
statement before the#elseif
or remove an incorrectly placed preceding#endif
.An
#elseif
has been detected that is preceded by an#else
or#endif
. Appropriately terminate the preceding#if
block, or change the preceding#else
to an#elseif
.
For additional information, select the item in question and press F1 (in Windows) or HELP (on the Macintosh).
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.