TheTreeMan
TheTreeMan

Reputation: 943

How do I automate the deletion of a worksheet?

I'm using Application.Sheets("Sheet6").Delete to delete a sheet, and it causes a popup that asks if I'm sure. How do I automatically select delete?

Upvotes: 0

Views: 98

Answers (3)

Declan_K
Declan_K

Reputation: 6826

Turn off the alerts before you do the delete. Then turn them back on like this:

Application.DisplayAlerts = False
    Application.Sheets("Sheet6").Delete
Application.DisplayAlerts = True

Upvotes: 1

kpark
kpark

Reputation: 394

You can turn your display alerts off for Excel

Application.DisplayAlerts = False
Application.Sheets("Sheet6").Delete
Application.DisplayAlerts = True

Upvotes: 1

Jaycal
Jaycal

Reputation: 2087

Update your code to disable the display of alerts before you delete your sheet; Then enable the alerts after the delete code executes

Application.DisplayAlerts = False
Sheets("Sheet6").Delete
Application.DisplayAlerts = True

Upvotes: 4

Related Questions