Handling Errors The Details

You can use the On Error statement in three ways, as shown in Table 12-1.

Table 12-1

Using the On Error Statement

Syntax

What It Does

On Error

After executing this statement, VBA resumes GoTo label

execution at the specified line. You must include a colon

after the label so that VBA recognizes it as a label.

On Error Resume Next

After executing this statement, VBA simply ignores all

errors and resumes execution with the next statement.

On Error GoTo 0 After executing this statement, VBA resumes its normal error-checking behavior. Use this statement after using one of the other On Error statements or when you want to remove error handling in your procedure.

0 0

Post a comment