Macro : confirm Delete

T

Tom

Dear,

I am useing this macro :

Sheets("XXX").Select
ActiveWindow.SelectedSheets.Delete

Then a messagebox appears to confirm to delete the data.
How can I klick "Delete" automatically (or avoid this
msgbox)?

Thanks !
Tom
 
B

Bob Phillips

Hi Tom,

Application.DisplayAlerts = False
Sheets("XXX").Select
ActiveWindow.SelectedSheets.Delete
Application.DisplaAlerts = True

as you are only deleting the one sheet it can also be simplified to

Application.DisplayAlerts = False
ActiveWorkbook.Sheets("XXX").Delete
Application.DisplaAlerts = True

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
G

Guest

Thank you !!

-----Original Message-----
Hi Tom,

Application.DisplayAlerts = False
Sheets("XXX").Select
ActiveWindow.SelectedSheets.Delete
Application.DisplaAlerts = True

as you are only deleting the one sheet it can also be simplified to

Application.DisplayAlerts = False
ActiveWorkbook.Sheets("XXX").Delete
Application.DisplaAlerts = True

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)




.
 
Top