VBA - Delete Worksheet With A Specific Name If It Exists
Application.DisplayAlerts = False
On Error Resume Next
ThisWorkbook.Sheets("Sheet1").Delete
On Error Goto 0
Application.DisplayAlerts = True
- The code between "On Error Resume Next" and "On Error Goto 0" will be skipped if an error is generated.
- It also won't display the error to the user because of the code on line 1 (Application.DisplayAlerts = False).
- "ThisWorkbook" will need to be declared.