Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How2 Delete "Not exist" charts/sheets?

Hi all,

I created the macro to delete charts..
Also I add a button to the menu and wanna click the button
to delete all the used charts.

The problem is: I wanna use one button to "clean" ALL the "used
charts,
but some of those charts may not exist (because I use different macr
to
create different charts), so Excel can not find them and will ask me t
debug.
e.g.
Sheets("Chart TC123").Select
ActiveWindow.SelectedSheets.Delete

and "Chart TC123" doesn't exist!
How to avoid the error message

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How2 Delete "Not exist" charts/sheets?

On Error Resume Next
Sheets("Chart TC123").Select
ActiveWindow.SelectedSheets.Delete
On Error goto 0

--
Regards,
Tom Ogilvy

"fatfish " wrote in message
...
Hi all,

I created the macro to delete charts..
Also I add a button to the menu and wanna click the button
to delete all the used charts.

The problem is: I wanna use one button to "clean" ALL the "used"
charts,
but some of those charts may not exist (because I use different macro
to
create different charts), so Excel can not find them and will ask me to
debug.
e.g.
Sheets("Chart TC123").Select
ActiveWindow.SelectedSheets.Delete

and "Chart TC123" doesn't exist!
How to avoid the error message?


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default How2 Delete "Not exist" charts/sheets?

fatfish wrote:

Hi all,

I created the macro to delete charts..
Also I add a button to the menu and wanna click the button
to delete all the used charts.

The problem is: I wanna use one button to "clean" ALL the "used"
charts,
but some of those charts may not exist (because I use different macro
to
create different charts), so Excel can not find them and will ask me
to debug.
e.g.
Sheets("Chart TC123").Select
ActiveWindow.SelectedSheets.Delete

and "Chart TC123" doesn't exist!
How to avoid the error message?


You could use something like this:

Sub DeleteMySheet(MySheetName As String)
Dim sh As Worksheet
For Each sh In ActiveWorkbook.Sheets
If sh.Name = MySheetName Then sh.Delete
Next sh
End Sub


--
To top-post is human, to bottom-post and snip is sublime.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How2 Delete "Not exist" charts/sheets?

Today is my lucky day:)

Thanks to Tom for your very simple and effective answer!
Thanks again to Amedee for your very logical solution! ;

--
Message posted from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How2 Delete "Not exist" charts/sheets?

Today is my lucky day:)

Thanks to Tom for your very simple and effective answer!
Thanks again to Amedee for your very logical solution! ;

--
Message posted from http://www.ExcelForum.com

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
Delete all sheets in workbook that contain "Dump" in the name Porr via OfficeKB.com Excel Worksheet Functions 2 May 19th 10 10:25 PM
User Defined Charts-Missing the "Add-Delete" Options. RUSH2CROCHET Excel Discussion (Misc queries) 0 February 15th 07 03:53 PM
User Defined Charts-Missing the "Add-Delete" Options. Joel Excel Discussion (Misc queries) 0 February 15th 07 03:46 PM
How do I delete Sheets if "Delete" is greyed out? carriemca Excel Discussion (Misc queries) 1 April 10th 06 05:31 PM
Adding "New" "Insert" "Delete" into a workbook to change from data 1 to data 2 etc Bob Reynolds[_2_] Excel Programming 0 March 4th 04 08:52 PM


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

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"