Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I don't really understand why need to
set c = nothing at the end? Martin's just cleaning up after himself. When object variables are set, it's better to clear them yourself than to rely on VB doing it. Just in case. - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions http://PeltierTech.com _______ "Terry" wrote in message ... Martin and Jon, Thanks alot. Martin's solution could be used for worksheets if dim c as worksheet Both of your solution works well for me. I don't really understand why need to set c = nothing at the end? "Martin Fishlock" wrote: Terry try this. It may need a little adapting as I'm not quite sure of your name specification. Option Explicit ' deletes all charts in the range ch0..ch9 Sub deletecharts() Dim c As Chart Dim chartname As String Application.DisplayAlerts = False For Each c In ActiveWorkbook.Charts chartname = LCase(c.Name) If Left(chartname, 2) = "ch" Then ' first two letters If IsNumeric(Mid(chartname, 3, 1)) Then ' next is number If Len(chartname) = 3 Then ' ok can delete it c.Delete End If End If End If Next c Set c = Nothing Application.DisplayAlerts = True End Sub -- Hope this helps Martin Fishlock Please do not forget to rate this reply. "Terry" wrote: I need to delete all worksheets with name contains "Ch", from "Ch1" until "Ch(n)". How to do it? All these sheets are charts. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel "Move or Copy" and "Delete" sheet functions | Excel Worksheet Functions | |||
How to delete sheets with "Ch" in the sheet name? | Excel Programming | |||
"With Sheets" Issue - macro on one sheet to affect hidden rows on other sheets | Excel Programming | |||
Supress "delete sheets" warning | Excel Programming | |||
How2 Delete "Not exist" charts/sheets? | Excel Programming |