Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sal Sal is offline
external usenet poster
 
Posts: 84
Default Delete Worksheets

I am using the following macro to delete worksheets in my workbook.

Sub Deleteworksheets()
Sheets("Current Asset").Select
ActiveWindow.SelectedSheets.Delete
Sheets("Current Liability").Select
ActiveWindow.SelectedSheets.Delete
Sheets("Long Term Asset").Select
ActiveWindow.SelectedSheets.Delete
Sheets("Long Term Liability").Select
ActiveWindow.SelectedSheets.Delete
End Sub


The obstacle I am having is that before each sheet deletes I am getting a
message box that reads €śData may exist in the sheet(s) selected for deletion.
To permanently delete the data, press Delete.€ť I would like to adjust the
macro I have so that it will override this message box and delete the sheets
I have indicated that I want to delete without checking if it is okay. Could
you advise me on how I might do this?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Delete Worksheets

Sub Deleteworksheets()
application.displayalerts = false
Sheets("Current Asset").Delete
Sheets("Current Liability").Delete
Sheets("Long Term Asset").Delete
Sheets("Long Term Liability").Delete
application.displayalerts = true
End Sub

--
HTH...

Jim Thomlinson


"Sal" wrote:

I am using the following macro to delete worksheets in my workbook.

Sub Deleteworksheets()
Sheets("Current Asset").Select
ActiveWindow.SelectedSheets.Delete
Sheets("Current Liability").Select
ActiveWindow.SelectedSheets.Delete
Sheets("Long Term Asset").Select
ActiveWindow.SelectedSheets.Delete
Sheets("Long Term Liability").Select
ActiveWindow.SelectedSheets.Delete
End Sub


The obstacle I am having is that before each sheet deletes I am getting a
message box that reads €śData may exist in the sheet(s) selected for deletion.
To permanently delete the data, press Delete.€ť I would like to adjust the
macro I have so that it will override this message box and delete the sheets
I have indicated that I want to delete without checking if it is okay. Could
you advise me on how I might do this?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default Delete Worksheets

On May 5, 3:58*pm, Sal wrote:
I am using the following macro to delete worksheets in my workbook.

Sub Deleteworksheets()
* * Sheets("Current Asset").Select
* * ActiveWindow.SelectedSheets.Delete
* * Sheets("Current Liability").Select
* * ActiveWindow.SelectedSheets.Delete
* * Sheets("Long Term Asset").Select
* * ActiveWindow.SelectedSheets.Delete
* * Sheets("Long Term Liability").Select
* * ActiveWindow.SelectedSheets.Delete
End Sub

The obstacle I am having is that before each sheet deletes I am getting a
message box that reads “Data may exist in the sheet(s) selected for deletion.
*To permanently delete the data, press Delete.” *I would like to adjust the
macro I have so that it will override this message box and delete the sheets
I have indicated that I want to delete without checking if it is okay. *Could
you advise me on how I might do this?


Sal,

You can use Application.DisplayAlerts = True/False. True shows the
message box result you are referring to, False does not show the
message box result you are referring to. Set DisplayAlters to False
prior to deletion and then set DisplayAlerts to True when you finish
your deletion.

Best,

Matthew Herbert
  #4   Report Post  
Posted to microsoft.public.excel.programming
Sal Sal is offline
external usenet poster
 
Posts: 84
Default Delete Worksheets

Thank you for your help. This works well now.

" wrote:

On May 5, 3:58 pm, Sal wrote:
I am using the following macro to delete worksheets in my workbook.

Sub Deleteworksheets()
Sheets("Current Asset").Select
ActiveWindow.SelectedSheets.Delete
Sheets("Current Liability").Select
ActiveWindow.SelectedSheets.Delete
Sheets("Long Term Asset").Select
ActiveWindow.SelectedSheets.Delete
Sheets("Long Term Liability").Select
ActiveWindow.SelectedSheets.Delete
End Sub

The obstacle I am having is that before each sheet deletes I am getting a
message box that reads €śData may exist in the sheet(s) selected for deletion.
To permanently delete the data, press Delete.€ť I would like to adjust the
macro I have so that it will override this message box and delete the sheets
I have indicated that I want to delete without checking if it is okay. Could
you advise me on how I might do this?


Sal,

You can use Application.DisplayAlerts = True/False. True shows the
message box result you are referring to, False does not show the
message box result you are referring to. Set DisplayAlters to False
prior to deletion and then set DisplayAlerts to True when you finish
your deletion.

Best,

Matthew Herbert

  #5   Report Post  
Posted to microsoft.public.excel.programming
Sal Sal is offline
external usenet poster
 
Posts: 84
Default Delete Worksheets

This works very well. Thank you for your help

"Jim Thomlinson" wrote:

Sub Deleteworksheets()
application.displayalerts = false
Sheets("Current Asset").Delete
Sheets("Current Liability").Delete
Sheets("Long Term Asset").Delete
Sheets("Long Term Liability").Delete
application.displayalerts = true
End Sub

--
HTH...

Jim Thomlinson


"Sal" wrote:

I am using the following macro to delete worksheets in my workbook.

Sub Deleteworksheets()
Sheets("Current Asset").Select
ActiveWindow.SelectedSheets.Delete
Sheets("Current Liability").Select
ActiveWindow.SelectedSheets.Delete
Sheets("Long Term Asset").Select
ActiveWindow.SelectedSheets.Delete
Sheets("Long Term Liability").Select
ActiveWindow.SelectedSheets.Delete
End Sub


The obstacle I am having is that before each sheet deletes I am getting a
message box that reads €śData may exist in the sheet(s) selected for deletion.
To permanently delete the data, press Delete.€ť I would like to adjust the
macro I have so that it will override this message box and delete the sheets
I have indicated that I want to delete without checking if it is okay. Could
you advise me on how I might do this?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA to delete worksheets Mark_F via OfficeKB.com Excel Discussion (Misc queries) 2 August 27th 09 06:04 PM
Delete All Worksheets, Except for Three ryguy7272 Excel Programming 1 March 16th 07 04:19 PM
I can't delete my worksheets Dillon Excel Discussion (Misc queries) 1 March 5th 07 06:10 PM
I can't delete my worksheets chuckmcc Excel Programming 7 March 17th 06 10:11 PM
Delete worksheets andym Excel Programming 6 November 24th 03 04:15 PM


All times are GMT +1. The time now is 05:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"