A Question About On Error Do X

Photomofo

Active Member
Joined
Aug 20, 2012
Messages
259
I don't have a lot of experience with On Error statements. I'm currently working on a program that has several failure mechanisms. Do I have to put On Error statements in each sub-routine or can I have a Global On Error statement that covers all the sub-routines?

I only have one On Error statement in this program currently. Assuming there is a way to set up a Global On Error condition will the current On Error statement supersede the Global On Error statement?
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
I believe that there is no Global On Error..

Here is good article on Or Error
 
Upvote 0
Its just a question of granularity. You can have the On Error Statement in the Top Sub Routine and if there is an error in a called subroutine with no error handling, the called sub as a whole will error out and the Top Sub On error statement will be invoked.
This will give very little indication of where the error actually occured and the on error action will need to be very non-specific.

Any error handling in a called subroutines will have a scope of just that sub routine (but will in turn cover any errors in the lower level routines that it calls, and don't have their own error handling)
 
Upvote 0

Forum statistics

Threads
1,214,795
Messages
6,121,624
Members
449,041
Latest member
Postman24

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