Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Delete Sheets" Error Message in Excel 1

Status
Not open for further replies.

Goska

Programmer
Jun 21, 2001
74
US
I have an Excel workbook being run by VBA. I am deleting some sheets that will not be used based on user button clicks to cut down on memory usage, since my program is being designed to run on a laptop. I can delete the sheets without a problem, but every time I run the program, an error message comes up asking if I am sure I want to delete these sheets. Is there a way to code into VBA to either automatically click "OK" or to disable this error box temporarily, then turn it back on?
 
lVar = Application.DisplayAlerts
Application.DisplayAlerts = False
Set oSheet = Application.ActiveWorkbook.Sheets("MySheet")
oSheet.Delete
Application.DisplayAlerts = lVar
Jon Hawkins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top