Deleting all worksheets in a workbook except two
Hi,
Try this:
Sub Test()
Set wb=ThisWorkbook
Application.DisplayAlerts=False
For i=wb.Sheets.Count to 1 Step -1
Select case wb.Sheets(i).Name
Case "Buttons", "Data"
Case Else: wb.Sheets(i).Delete
End Select
Next i
Application.DisplayAlerts=True
End Sub
Regards,
KL
"lewscannon" wrote in message
...
I would like to write a macro that deletes all worksheets in a workbook
except for two, called "Buttons" & "Data". The problem is that the amount
of
and names of the worksheets won't be static, so I can't simply write
"Worksheets ("Sheet1").Delete". I thank you in advance for your help.
|