ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   What is the VBA code to delete a sheet without warning message? (https://www.excelbanter.com/excel-discussion-misc-queries/39457-what-vba-code-delete-sheet-without-warning-message.html)

[email protected]

What is the VBA code to delete a sheet without warning message?
 
I have the following code to delete a tab:

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

When I run this, I get the standard "You may lose data" warning
message. Does a different syntax allow me to delete the sheet without
getting the warning message?

Thanks


Dennis


Application.DisplayAlerts = False
Sheets("Your Sheet").Delete
Application.DisplayAlerts = True

HTH Dennis


" wrote:

I have the following code to delete a tab:

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

When I run this, I get the standard "You may lose data" warning
message. Does a different syntax allow me to delete the sheet without
getting the warning message?

Thanks



[email protected]

Thanks!



All times are GMT +1. The time now is 04:38 PM.

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