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 ask the user to confirm the delete because of the code on line 1 (Application.DisplayAlerts = False).