Delete hidden worksheets

  • Thread starter Thread starter Shamsul Islam
  • Start date Start date
S

Shamsul Islam

Hi

What code can be used to delete all hidden worksheets?

Thanks

Sham
 
Hi
try
Sub delete_hidden()
Dim wkSht As Worksheet
For Each wkSht In ActiveWorkbook.Worksheets
If wkSht.Visible <> True Then
wkSht.Delete
End If
Next wkSht
End Sub

this will delete all sheets that are not visible (xlSheetHidden and
xlSheetVeryHidden)
 
Sub DeleteHidden()
Dim sh As Worksheet
Application.DisplayAlerts = False
For Each sh In ActiveWorkbook.Worksheets
If sh.Visible = xlHidden Or sh.Visible = xlVeryHidden Then
sh.Delete
End If
Next sh
Application.DisplayAlerts = True
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top