\<bookmark_value\>End statement\</bookmark_value\>

End Statement

Ends a procedure or block.

Syntax:


End, End Enum, End Function, End If, End Property, End Select, End Sub, End With

Parameters:

Use the End statement as follows:

Statement

End: Is not required, but can be entered anywhere within a procedure to end the program execution.

End Enum: Ends an Enum VBA statement

End Function: Ends a \<emph\>Function\</emph\> statement.

End If: Marks the end of a \<emph\>If...Then...Else\</emph\> block.

End Property: Marks the end of a Property statement.

End Select: Marks the end of a \<emph\>Select Case\</emph\> block.

End Sub: Ends a \<emph\>Sub\</emph\> statement.

End With: Ends a With statement

Example:


Sub ExampleRandomSelect
Dim iVar As Integer
    iVar = Int((15 * Rnd) -2)
    Select Case iVar
        Case 1 To 5
            Print "Number from 1 to 5"
        Case 6, 7, 8
            Print "Number from 6 to 8"
        Case Is > 8 And iVar < 11
            Print "Greater than 8"
        Case Else
            Print "Outside range 1 to 10"
    End Select
End Sub

Please support us!