Excel VBA Programming For Dummies by Michael Alexander

Excel VBA Programming For Dummies by Michael Alexander

Author:Michael Alexander
Language: eng
Format: epub, azw3
ISBN: 9781119518242
Publisher: Wiley
Published: 2018-11-06T00:00:00+00:00


Handling Errors Another Way

How can you identify and handle every possible error? Often, you can’t. Fortunately, VBA provides another way to deal with errors.

Revisiting the EnterSquareRoot procedure

The following code is a modified version of the procedure from the previous section. Here, an all-purpose On Error statement traps all errors and then checks to see whether the InputBox was canceled.

Sub EnterSquareRoot5()

Dim Num As Variant

Dim Msg As String

' Set up error handling

On Error GoTo BadEntry

' Prompt for a value

Num = InputBox("Enter a value")

' Exit if cancelled

If Num = "" Then Exit Sub



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.