ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deleting a sheet with VBA (https://www.excelbanter.com/excel-programming/420487-deleting-sheet-vba.html)

hamishd

Deleting a sheet with VBA
 
Hi, i'm using the line:
Sheets("Sheet2").Delete

However, on execution, I get a warning messagebox:
"Data may exist in the sheet(s) selected for deletion. To permanently
delete the data, press Delete."

How do I suppress messages of these types?

Thanks.

Gary Keramidas

Deleting a sheet with VBA
 
and if you set it to false, make sure you always set it back to true

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

--


Gary

"hamishd" wrote in message
...
Hi, i'm using the line:
Sheets("Sheet2").Delete

However, on execution, I get a warning messagebox:
"Data may exist in the sheet(s) selected for deletion. To permanently
delete the data, press Delete."

How do I suppress messages of these types?

Thanks.




RadarEye

Deleting a sheet with VBA
 
Hi,

Try:

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

HTH,

Wouter


All times are GMT +1. The time now is 10:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com