Else If, Else, or End If must be preceded by a matching If
Else If, Else, and End If are conditional compilation directives. This error has the following cause and solution:
An #elseif
, #else
, or #endif
was detected that isn't preceded by a matching #if
clause. Check to see if the intended #if
has been separated from the clause in question by an intervening block or if the intended #if
is preceded by a number sign (#
) sign. If everything else is in order, place an #if
clause in the appropriate position.
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.