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]
 

Some videos you may like

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Oaktree

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

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,047
Office Version
  1. 365
Platform
  1. Windows
Try turning off DisplayAlerts.
Code:
Application.DisplayAlerts=False
' your code here
Application.DisplayAlerts=True
 

Watch MrExcel Video

Forum statistics

Threads
1,118,100
Messages
5,570,213
Members
412,309
Latest member
Benky
Top