Error handling

G

GPO

(excel 2000, 2003, 2007)

Hello All

I have a function where I want the error handling for the most part to be
On Error GoTo HandleError

but for certain blocks I want it to be
On Error Resume Next

How do I do this?

Regards

GPO
 
J

Joel

Just switch between the two errors mode as required

On Error GoTo HandleError
'section 1 code
On Error Resume Next
'section 2 code
 
B

Bob Phillips

I tend to handle that by placing the Resume Next code into a separate
procedure, as the error handler is reset on exit.

Sub TestError()

On Error GoTo HandleError

'do stuff

Call CalledProc

Debug.Print 1 / 0

Exit Sub

HandleError:
MsgBox Err.Number & " : " & Err.Description
End Sub

Function CalledProc()

On Error Resume Next
Debug.Print 1 / 0
End Function

It may seem unnecessary, but I find it keeps the code more structured, and
gives m e all the control that I need
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Error Handling 1
Adding multiple handling errors 0
Error handling best practices 4
Error Handling construct 11
Global Error Handling 2
Write to MS Word 3
GetKeyBoardState Function 1
Copy filtered data to sheet 2 1

Top