ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to delete sheets with "Ch" in the sheet name? (https://www.excelbanter.com/excel-programming/378547-re-how-delete-sheets-ch-sheet-name.html)

Jon Peltier

How to delete sheets with "Ch" in the sheet name?
 
If they are charts, then they are chart sheets, not worksheets. Worksheets
have rows and columns and cells and stuff.

Semantics aside, use the first to delete all chart sheets, or the second to
delete those with names containing "ch"

Sub DeleteAllChartSheets()
Application.DisplayAlerts = False ' suppress warning message
ActiveWorkbook.Charts.Delete
Application.DisplayAlerts = True
End Sub

Sub DeleteChartSheetsNamed_CH_()
Dim ch As Chart
For Each ch In ActiveWorkbook
If InStr(LCase$(ch.Name), "ch") 0 Then
ch.Delete
End If
Next
End Sub

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Terry" wrote in message
...
I need to delete all worksheets with name contains "Ch", from "Ch1" until
"Ch(n)". How to do it? All these sheets are charts.





All times are GMT +1. The time now is 05:58 PM.

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