Problems with error trapping using Excel macros (Visual Basic coding)

Al Kremer 0 Reputation points
2026-10-16T21:35:50.06+00:00

I am developing an Excel macro and am having trouble with error trapping.

Here is the actual code I am using:

'Select Name Tab

   On Error GoTo NEXTA

   Sheets(Name).Select

   GoTo NEXTB

NEXTA:

   Call Add_A_Name(Name, EnvNo)

NEXTB:

   On Error GoTo 0

The first time this code is executed, it works fine. However, the second time through the 'On Error GoTo NEXTA' statement is ignored, despite the fact that it is reset with the 'On Error GoTo 0' code. I have experienced this problem before using other logic but before, I was able to work around the problem. This time I can't. Why?

Developer technologies | Visual Basic for Applications
0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.