How do you tell Excel to resume recognizing errors?

Monsignor

Board Regular
Joined
May 30, 2011
Messages
162
There is 1 section of my code where errors don't matter. I would like to use
On Error Resume Next

However, for the rest of the code, I'd like it to go back to recognizing errors.

===
More detail:

My code is copying the "Policies" worksheet and creating a "Policies2" worksheet.

I want to start the macro by deleting an existing "Policy2" if it exists. If it doesn't exist, then get on with the real work. I don't want the macro to tell me it can't find "Policies2"
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
It didn't work. Errors still show up unless I use On Error Resume Next.

Here the section of code:

Code:
Sub SubTTL()
'
' SubTTL Macro
'
'Unprotect sheet
ActiveSheet.Unprotect

'Delete Policies2 sheet--if any

Sheets("Policies (2)").Select
    ActiveWindow.SelectedSheets.Delete

'Select Policies Page and make a copy
    Sheets("Policies").Select
    Sheets("Policies").Copy Before:=Sheets(1)
    Cells.Select

The idea is to look to see if there's Policies (2). If yes, delete it.
 
Upvote 0
Got it!

Code:
Sub SubTTL()
'
' SubTTL Macro
'
'Unprotect sheet
ActiveSheet.Unprotect

'Delete Policies2 sheet--if any
Application.DisplayAlerts = False

On Error GoTo CSheet
Sheets("Policies (2)").Select
    ActiveWindow.SelectedSheets.Delete
Application.DisplayAlerts = True

CSheet:
'Select Policies Page and make a copy
    Sheets("Policies").Select
 
Upvote 0

Forum statistics

Threads
1,214,665
Messages
6,120,804
Members
448,990
Latest member
rohitsomani

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