ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   macro to delete a sheet (https://www.excelbanter.com/excel-programming/275943-macro-delete-sheet.html)

MoiraGunn

macro to delete a sheet
 
I know this is an easy one but I need some help.
I'd like to delete a sheet in my macro but I keep getting a dialog box that
asks me if I'm sure I want to delete the sheet. I want to bypass this
automatically but don't know how. Any help is appreciated.
Example of the 2 lines I'm stuck on.

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

I'm using Excel 97.

Thanks Kathy



J.E. McGimpsey

macro to delete a sheet
 
one way:

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

Note that you don't have to select the sheet first.

In article ,
"MoiraGunn" wrote:

I know this is an easy one but I need some help.
I'd like to delete a sheet in my macro but I keep getting a dialog box that
asks me if I'm sure I want to delete the sheet. I want to bypass this
automatically but don't know how. Any help is appreciated.
Example of the 2 lines I'm stuck on.

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

I'm using Excel 97.

Thanks Kathy



MoiraGunn

macro to delete a sheet
 
Excellent - this works! Thanks very much -

"J.E. McGimpsey" wrote in message
...
one way:

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

Note that you don't have to select the sheet first.

In article ,
"MoiraGunn" wrote:

I know this is an easy one but I need some help.
I'd like to delete a sheet in my macro but I keep getting a dialog box

that
asks me if I'm sure I want to delete the sheet. I want to bypass this
automatically but don't know how. Any help is appreciated.
Example of the 2 lines I'm stuck on.

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

I'm using Excel 97.

Thanks Kathy






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

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