Resuming after an error
One way of handling errors is to display a dialog box with some explanation as to why the procedure stopped. It's rather abrupt, though, sometimes leaving us with a lack of full understanding as to what really happened. Furthermore, we are often unsure as to what we should do after closing the dialog box.
In cases where we want to recover from errors, the Resume
statement will achieve this.
In this recipe, we will be resuming after errors occurred in three different ways.
Getting ready
With ErrorHandling.xlsm
still open, and Sheet1 active, arrange the Excel and VBA Editor windows in such a way that both are visible next to each other.
How to do it…
Insert a new module and follow these steps:
- Enter the following code:
Sub Test()     Dim Num As Variant     Dim Msg As String     Dim Answer As Integer TryAgain:     On Error GoTo WrongEntry &...