Delete Tab w/o prompt [solved]

goldfish

Well-known Member
Joined
Aug 23, 2005
Messages
712
I'm writting a macro, which partially involves deleting worksheets. Currently I'm just using

Worksheets(WS).Delete

where WS is dim as a worksheet

But when this command is run, the message "Data may exist in the sheet(s) selected for deletion. To permanently delete the data, press Delete." which freezes the macro and waits for the users response. Is there a way to make this message not pop up either in excel options? or preferably an override in the VB code?

Thanks so much![/code]
 

Oaktree

MrExcel MVP
Joined
Jun 20, 2002
Messages
7,937
Code:
Application.DisplayAlerts = False
Worksheets(WS).Delete
Application.DisplayAlerts = True
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,275
Try turning off DisplayAlerts.
Code:
Application.DisplayAlerts=False
' your code here
Application.DisplayAlerts=True
 

Forum statistics

Threads
1,077,866
Messages
5,336,857
Members
399,109
Latest member
gdcuk

Some videos you may like

This Week's Hot Topics

Top