ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   avoid warning when removing sheet (https://www.excelbanter.com/excel-programming/349037-avoid-warning-when-removing-sheet.html)

Tijmen

avoid warning when removing sheet
 
I want to remove all sheets except of sheet 1 by a macro

iSheetMax = Sheets.Count

' Delete other sheets
For iSheet = 2 To iSheetMax
Sheets(2 + iSheetMax - iSheet).Delete
Next

Then the user gets a warning message (warns for permanently deleting of
sheet).
I do not want this.

How can I prevent the warning message to appear?

Thanks,

Tijmen



Norman Jones

avoid warning when removing sheet
 
Hi Tijimen.

Try:

iSheetMax = Sheets.Count


Application.DisplayAlerts = False


' Delete other sheets
For iSheet = 2 To iSheetMax
Sheets(2 + iSheetMax - iSheet).Delete
Next


Application.DisplayAlerts = True


---
Regards,
Norman


"Tijmen" wrote in message
...
I want to remove all sheets except of sheet 1 by a macro

iSheetMax = Sheets.Count

' Delete other sheets
For iSheet = 2 To iSheetMax
Sheets(2 + iSheetMax - iSheet).Delete
Next

Then the user gets a warning message (warns for permanently deleting of
sheet).
I do not want this.

How can I prevent the warning message to appear?

Thanks,

Tijmen




Snake Plissken[_2_]

avoid warning when removing sheet
 

like this I suppose:

iSheetMax = Sheets.Count

' Delete other sheets
application.DisplayAlerts =False
For iSheet = 2 To iSheetMax
Sheets(2 + iSheetMax - iSheet).Delete
Next
application.DisplayAlerts =true





All times are GMT +1. The time now is 02:52 AM.

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