ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can't Raise Error twice (https://www.excelbanter.com/excel-programming/357500-cant-raise-error-twice.html)

DzednConfsd[_2_]

Can't Raise Error twice
 
What am I doing wrong? The second time the sub CallMe is called, I get
the VB Runtime error instead of the error passing back to the calling
procedure and being dealt with there.
Thanks for your help.
Sub test()
Dim x As Integer
On Error GoTo test_Error

NEXTACCOUNT:

For x = 1 To 10
callme
Next

Exit Sub
test_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in
procedure test of Module Module1"
Err.Clear
GoTo NEXTACCOUNT
End Sub

Sub callme()
Err.Raise 2500, "callme", "Testing"
End Sub


Chip Pearson

Can't Raise Error twice
 
You need to RESUME NEXTACCOUNT rather than GOTO NEXTACCOUNT.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"DzednConfsd" wrote in message
ups.com...
What am I doing wrong? The second time the sub CallMe is
called, I get
the VB Runtime error instead of the error passing back to the
calling
procedure and being dealt with there.
Thanks for your help.
Sub test()
Dim x As Integer
On Error GoTo test_Error

NEXTACCOUNT:

For x = 1 To 10
callme
Next

Exit Sub
test_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ")
in
procedure test of Module Module1"
Err.Clear
GoTo NEXTACCOUNT
End Sub

Sub callme()
Err.Raise 2500, "callme", "Testing"
End Sub





All times are GMT +1. The time now is 07:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com