Error Handling

jaybee3

Active Member
Joined
Jun 28, 2010
Messages
307
Hi all, first time trying to tackle error handling to any real degree and I just wanted a few suggestions/tips. The below is the basic overview of my code for my errors. Not capturing them individually as of yet. I was wondering does the error handling carry propogate through called subs? Or do I need to include it in what's called too?

If so, do you guys actually add error handling to each individual sub or is there a better way to pick up the errors?

Overview of the code: My Menu has a series of buttons, which will call the following procedures (button_Phasex_Stepx), which will then inturn call the required subs within. phaseCompleted is purely for formatting on the cells' interiors where the buttons are (Green if it completes, Red if it fails, Blank to just reset it)

Code:
Sub button_Phase1_Step1

     eHandling array("Macro1","Macro2"),1,1

End Sub

Sub button_Phase1_Step2

     eHandling array("Macro3","Macro4","Macro5","Macro6"),1,2

End Sub

...

Sub eHandling(sSubs As Variant, iPhase As Integer, iStep As Integer)
Dim iSubs As Integer
On Error GoTo eHandle: phaseCompleted iPhase, iStep, psReset
    For iSubs = LBound(sSubs) To UBound(sSubs)
    
        Application.Run sSubs(iSubs)
        
    Next iSubs
    phaseCompleted iPhase, iStep, psCompleted
    Exit Sub
eHandle: phaseCompleted iPhase, iStep, psFailed

End Sub

Any help/hints/trips would be great!
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Forum statistics

Threads
1,223,907
Messages
6,175,301
Members
452,633
Latest member
DougMo

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