End... Statement |
Syntax
End Enum End Function End If End Property End Select End Sub End Type End With
Description
Ends a procedure or a block of code.
Rules at a Glance
The End statement is used as follows:
Statement | Description |
---|---|
End | Terminates program execution. |
End Enum | Marks the end of an enumerated type. |
End Function | Marks the end of a Function procedure. |
End If | Marks the end of an If...Then...Else statement. |
End Property | Marks the end of a Property Let, Property Get, or Property Set procedure. |
End Select | Marks the end of a Select Case statement. |
End Sub | Marks the end of a Sub procedure. |
End Type | Marks the end of a user-defined type definition. |
End With | Marks the end of a With statement. |
Programming Tips and Gotchas
Although supported, the End statement used by itself to terminate the program shouldn't be used within a VBA application. Instead you should terminate execution of a procedure prematurely using the Exit... statement.
See Also
- Exit... Statement
Get VB & VBA in a Nutshell: The Language now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.