Dear Gurus,
I recently encountered this issue when writing an error handling section inside a For loop (VBA for Excel). It seems that the On Error status resets to GoTo 0 after the first time an error has been handled.
To illustrate this, in the following situation, I expected 5 Message Boxes but I only get 1. After the error handler activates the next loop, the On Error GoTo NextFor seems to have lost its meaning. My purpose is to have a "On Error GoTo Next Loop" mechanism in place. Could you please help?
Sub test()
For i = 1 To 5
On Error GoTo NextFor
Worksheets("NoSuchWorksheet").Activate
NextFor:
MsgBox "At i = " & i & ", Loop Jumped to NextFor"
Next
End Sub
Bookmarks