Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default On Close Macro - stop warning message

I have this macro on close:

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

I need to do two things.

1) If the sheet doesn't exist I want the macro to do
nothing and carry on to delete the next worksheet.

2) If the sheet does exist I want the macro to delete it
without the warning.

Any help is much appreciated.
Many thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default On Close Macro - stop warning message

You can avoid the error by:

on error resume next
sheets("bakery").delete
on error goto 0

(But what does Next mean if that worksheet doesn't exist?)

And to hide the warning message:

application.displayalerts = false
on error resume next
sheets("bakery").delete
on error goto 0
application.displayalerts = true

and you can delete as many sheets as you want in that little bit of code:

application.displayalerts = false
on error resume next
sheets("bakery").delete
sheets("butcher").delete
sheets("candlestickmaker").delete
on error goto 0
application.displayalerts = true



M Shannon wrote:

I have this macro on close:

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

I need to do two things.

1) If the sheet doesn't exist I want the macro to do
nothing and carry on to delete the next worksheet.

2) If the sheet does exist I want the macro to delete it
without the warning.

Any help is much appreciated.
Many thanks


--

Dave Peterson

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default On Close Macro - stop warning message

On Error Resume Next
Application.Displayalerts = False
Sheets("Bakery").Delete
Applicaton.displayAlerts = True
On Error goto 0

--
Regards,
Tom Ogilvy



"M Shannon" wrote in message
...
I have this macro on close:

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

I need to do two things.

1) If the sheet doesn't exist I want the macro to do
nothing and carry on to delete the next worksheet.

2) If the sheet does exist I want the macro to delete it
without the warning.

Any help is much appreciated.
Many thanks



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
Macro Warning Message Tendresse Excel Discussion (Misc queries) 0 February 29th 08 07:44 AM
Macro Warning Message Lisa Neron Excel Discussion (Misc queries) 5 January 16th 08 01:27 AM
Stoping the Macro Warning Message Jurrasicway Excel Discussion (Misc queries) 5 June 19th 06 02:56 PM
Warning message on file close Lambtwo Excel Worksheet Functions 1 October 25th 05 03:31 AM
Code & modules are gone, Macro warning message remains David McRitchie Excel Programming 1 September 10th 04 11:17 PM


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

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

About Us

"It's about Microsoft Excel"