Not all keywords can appear at the beginning of a line of code. This error has the following causes and solutions:
A Sub, Function, or Property statement must always be the first statement on any line in which it appears (unless preceded by the keyword Public, Private, or Static).
An End If, Else, or ElseIf (only when used in a block If structure) statement must always be the first statement on any line in which it appears.
For additional information, select the item in question and press F1 (in Windows) or HELP (on the Macintosh).