Multiple On Error Statements

MikeDBMan

Well-known Member
Joined
Nov 10, 2010
Messages
591
I want to put some error checking in my code but I can't seem to figure out how to have multiple "On Error Goto XXX" statements in the same Sub. Someone said to place "Resume" statements in the code but I can't figure out how to make it work. Below are 2 "On Error" statements. The line Sheets("asdf").Select should be skipped because that tab does NOT exist but instead I get an error message. What am I doing wrong? Thanks!

Code:
Sub testit()
On Error GoTo AfterSkipped
 
'blah blah blah  code and more code....
 
Resume AfterSkipped
GoTo AfterSkipped
 
AfterSkipped:
On Error GoTo NextErr
Sheets("asdf").Select
 
NextErr:
End Sub
 

Some videos you may like

Excel Facts

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

Watch MrExcel Video

Forum statistics

Threads
1,127,205
Messages
5,623,363
Members
415,969
Latest member
Rey99

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
Top