PDA

View Full Version : Solved: Keep the only Sheet



sukumar.vb
08-26-2011, 04:57 PM
When I open an Excel workbook, I want to keep only one sheet name "Hello" and I want to delete other sheets which were created in last session.

Therefore, Excel should delete all other sheets, except one sheet.

Aussiebear
08-27-2011, 02:40 AM
Try the following on a copy of a workbook, and if it works to your satisfaction then we only need to change the action to a BeforeClose event and reside the code within the This Workbook module

Sub deletesheets()
Dim ws As Worksheet
Application.DisplayAlerts = False
For Each ws In ThisWorkbook.Worksheets
If ws.Name <>"Hello" Then ws.Delete
Next ws
End Sub

sukumar.vb
08-28-2011, 04:04 AM
Thanks ... :friends:

There can be Charts also along with sheets. How to delete Charts?
Could there be anything else, along with Charts?
How to mark this thread as "Solved"?

Thanks ... :friends:



Try the following on a copy of a workbook, and if it works to your satisfaction then we only need to change the action to a BeforeClose event and reside the code within the This Workbook module

Sub deletesheets()
Dim ws As Worksheet
Application.DisplayAlerts = False
For Each ws In ThisWorkbook.Worksheets
If ws.Name <>"Hello" Then ws.Delete
Next ws
End Sub

sukumar.vb
08-28-2011, 04:42 PM
Thanks...

:beerchug: