Only comments may appear after End Sub, End Function, or End Property
Only comments, directives, and declarations are permitted outsideprocedures. This error has the following cause and solution:
- You placed executable code outside a procedure. Any nondeclarative lines outside a procedure must begin with a comment delimiter ('). Declarative statements must appear before the first procedure declaration. Comments are ignored when the code executes.
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.