Thread: Delete sheets
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default Delete sheets

Try the below macro and feedback. This works on the active workbook

Sub DeleteSheets()
strSheets = "Elevdata,Rapportvalidering,Kontrollark,Samlea rk"
Application.DisplayAlerts = False
For intTemp = Sheets.Count To 1 Step -1
If InStr(1, "," & strSheets & ",", "," & _
Sheets(intTemp).Name & ",", vbTextCompare) = 0 Then
Sheets(intTemp).Delete
End If
Next
Application.DisplayAlerts = True
End Sub

--
If this post helps click Yes
---------------
Jacob Skaria


"Sverre" wrote:

I have a workbook with many diefferent sheets. I need a makro to delete all
sheets except 4 sheets named:
Elevdata,
Rapportvalidering,
Kontrollark,
Samleark,

It is not possible to record a makro because the sheets can appear with
different names.

Regards Sverre