Error Handling

seacrest

Active Member
Joined
Aug 15, 2002
Messages
301
How do you call another macro using a error handler

not a handler within the macro
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Code:
Private ErrorMsg As String

Sub CallerMacro()
    On Error GoTo CallerMacro_Error
    
    'do some stuf
    
    If Not CalledMacro Then Err.Raise 99999
    
    'some more stuff
    
CallerMacro_Exit:
    Exit Sub
    
CallerMacro_Error:
    MsgBox ErrorMsg, vbOKOnly + vbCritical, "Error In Application!2"
End Sub

Function CalledMacro() As Boolean

    On Error GoTo CalledMacro_Error
    
    CalledMacro = True
    
    Debug.Print 1 / 0
    
CalledMacro_Exit:
    Exit Function
    
CalledMacro_Error:
    CalledMacro = False
    ErrorMsg = "Error In CalledMacro" & vbNewLine & _
               "Error num: " & Err.Number & vbNewLine & _
               "Message: " & Err.Description
    Resume CalledMacro_Exit

End Function
 
Upvote 0

Forum statistics

Threads
1,215,539
Messages
6,125,403
Members
449,222
Latest member
taner zz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top