View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Error handler resume

You case statement appears screwed up. why shift to an if statement.

Anyway, this worked for me:

Sub Main()
On Error GoTo ErrHandler

Test
For i = 1 To 10
j = j + 1
Next i
Exit Sub
ErrHandler:
MsgBox "In Main Error Handler"
End Sub

Sub Test()
On Error GoTo Handler

Err.Raise 666
MsgBox "Line After error 666"
Handler:
Select Case Err.Number
Case 600
MsgBox "Error is 600"

Case 666
MsgBox "Error is 666"
Resume Next
End Select

End Sub


--
Regards,
Tom Ogilvy

"Arne Hegefors" wrote:

I have a sub in which I call an error handler if certain requirements are
met. I call the error handler and give a message to the user but I want to
continue where the error was. Now it contnues in the main sub for some
reason.

Code for error handler:

Handler:
Select Case Err.Number
Case 600
.......
If Err.Number = 666 Then
Resume Next
End If
end select

and in the sub I call the error handler for that particukar error using:

Err.Raise 666

Please help me out here! Many thanks in advance!