Exit

This statement exits a block of Do...Loop, For...Next, Function, or Sub code.

Syntax

Exit Do

Exit For

Exit Function

Exit Sub

The following list shows the forms for the Exit statement syntax:

Exit Do
Provides a way to exit a Do...Loop statement.
Exit For
Provides a way to exit a For loop.
Exit Function
Immediately exits the Function procedure in which it appears.
Exit Sub
Immediately exits the Sub procedure in which it appears.