PDA

View Full Version : [SOLVED] delete all sheets and charts except "Input"



asdzxc
09-01-2013, 09:20 PM
Sub delete()
Dim ws As Worksheet
Application.DisplayAlerts = False
For Each ws In Worksheets
If ws.Name <> "Input" Then ws.delete
Next
Application.DisplayAlerts = True
End Sub

the above vba delete all sheets except "Input" but not the charts. I want all charts to be deleted also.

p45cal
09-01-2013, 09:46 PM
Sub delete()
Dim ws 'no As Worksheet
Application.DisplayAlerts = False
For Each ws In Sheets 'not WorkSheets
If ws.Name <> "Input" Then ws.delete
Next
Application.DisplayAlerts = True
End Sub

asdzxc
09-01-2013, 10:10 PM
after Excel file is closed and re-open, all the sheets were deleted except "Input" and the charts and I need to apply macro "delete" again to
delete the charts

p45cal
09-01-2013, 10:42 PM
after Excel file is closed and re-open, all the sheets were deleted except "Input" and the charts and I need to apply macro "delete" again to
delete the chartsWhat?!?

asdzxc
09-01-2013, 11:59 PM
SOLVED