How to Delete Hidden Sheets in Excel (2 Effective Methods)

 

Method 1 – Remove Hidden Sheets by Applying the Inspect Document Function in Excel

We’ve hidden some sheets in the workbook.

Remove Hidden Sheets Applying Inspect Document Function in Excel

Steps:

  • Click the File tab.

Remove Hidden Sheets Applying Inspect Document Function in Excel

  • Go to Info, then to Check for Issues, and select Inspect Document.
  • The Document Inspector dialog box will open up.

section

  • Press Inspect.

  • Scroll down and select Remove All from the Hidden Worksheets section.

Remove Hidden Sheets Applying Inspect Document Function in Excel

  • Press Close to quit the dialog box.

  • The Unhide option is blurred which means all the hidden sheets are deleted.

Read More: [Fixed!] Delete Sheet Not Working in Excel


Method 2 – Delete Hidden Sheets Using VBA Macros in Excel

Macro 1 – Delete with a Confirmation Pop-up

Steps:

  • Right-click on the sheet title.
  • Select View Code from the Context menu.
  • A VBA window will appear. You can press Alt+F11 to open the VBA window directly.

Delete Hidden Sheets Using VBA Macros in Excel

  • Insert the following code in the VBA window-
Sub Delete_Hidden_Sheets()
j = 1
While j <= Worksheets.Count
If Not Worksheets(j).Visible Then
Worksheets(j).Delete
Else
j = j + 1
End If
Wend
End Sub
  • Press the Run icon to run the code.

Delete Hidden Sheets Using VBA Macros in Excel

  • A pop-up confirmation box will open.
  • Press Delete.

Delete Hidden Sheets Using VBA Macros in Excel

  • Excel has deleted all hidden sheets and made the Unhide option blurred.

Macro 2 – Delete with a Confirmation Message

Steps:

  • Open the VBA window by clicking the View Code option from the Context menu after right-clicking on any sheet title.

Delete Hidden Sheets Using VBA Macros in Excel

  • Insert the following code in it:
Sub Delete_Hidden_Sheets()
Dim x As Worksheet
ConfirmMacro = MsgBox("Are you sure to delete all the hidden sheets?", vbYesNo, " CONFIRMATION! ")
    If ConfirmMacro = vbNo Then
    Exit Sub
    Else
End If
With Application
  .DisplayAlerts = False
  For Each x In Worksheets
    If x.Visible = xlVeryHidden Then x.Visible = Hidden
    If Not x.Visible Then x.Delete
  Next x
  .DisplayAlerts = True
End With
End Sub
  • Press the Run icon.

Delete Hidden Sheets Using VBA Macros in Excel

  • A confirmation dialog box will pop up.
  • Press Yes to confirm.

Delete Hidden Sheets Using VBA Macros in Excel

  • All the hidden sheets are deleted, with no Unhide option.

Macro 3 – Delete without Any Confirmation

Steps:

  • Select View Code from the Context menu after right-clicking on any sheet title.

Delete Hidden Sheets Using VBA Macros in Excel

  • After opening the VBA window, insert the following code:
Sub Remove_Hidden_Sheets()
Dim j As Integer
Dim X as Worksheet
  Application.DisplayAlerts = False
  For Each X In ActiveWorkbook.Sheets
      If X.Visible = xlSheetHidden Then
        X.Delete
        j = j + 1
      End If
  Next X
  Application.DisplayAlerts = True
End Sub
  • Click the Run icon to run the macro.

Delete Hidden Sheets Using VBA Macros in Excel

  • No Unhide option means no hidden sheets exist.


Things to Remember

  • After deleting hidden sheets, there is no way to undo or recover them. So, make sure you have created a backup.
  • If you haven’t saved the file after deleting it, close the workbook without saving it and open it again. Then you will get back the sheets.

Download the Practice Workbook


Related Articles


<< Go Back to Delete Sheet | Worksheets | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Md. Sourov Hossain Mithun
Md. Sourov Hossain Mithun

Md. Sourov Hossain Mithun, an Excel and VBA Content Developer at Softeko's ExcelDemy project, joined in October 2021. Holding a Naval Architecture & Marine Engineering degree from BUET, Mithun showcases expertise during his two-year tenure. With over 200 published articles on Excel topics, he earned a promotion to Team Leader, excelling in leading diverse teams. Mithun's passion extends to Advanced Excel, Excel VBA, Data Analysis, and Python programming, contributing significantly to the innovative and dynamic environment of ExcelDemy... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo