View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Patrick Molloy Patrick Molloy is offline
external usenet poster
 
Posts: 1,049
Default First Error works but Subsequent Error Handling Does Not

VBA error handling is a little primitive

ON ERROR RESUME NEXT
is popular but one should avoid it in complex procedures (IMHO)

ON ERROR GOTO errorline
sets the trap - and an error condition switches the code to the line
referenced

ON ERROR GOTO 0
this switches off the previous ON ERROR statement.


"Edwin Kelly" wrote in message
...
I have a module that has fairly detailed error handling (many error
codes).
When I get multiple errors with the exact same error code, it catches the
first one but not the subsequent ones. It does not do this for all error
codes, just one in particular that I can see so far. The error is
generated
by another object.
I've seen posts on this but when I enter a GoTo 0 it says it is not a
defined label. Not exactly sure where this needs to be because I need the
error handler to put something in a cell indicating the error. Not sure
how
else to do this. Any help is much appreciated.
I have an Err.Clear at the end but it does not help. Any ideas? Here is
the snippet in the error handler.
--- code snippet ---
ErrorHandler:

If Err.Number = -2147220985 Then
Debug.Print Loop1 & " of " & (lLastRow - 3) & " Tag:" & sTagname & "
Error:" & Err.Number & " Desc:" & Err.Description
ActiveCell.Offset(0, 6).Value = "Ivalid Tagname"
Err.Clear
GoTo NextNoTag
...more error codes handled below this
--
Edwin Kelly
Houston, TX