If there are some hidden worksheets exist in excel and you want delete them as they are not useful, you can unhide all worksheets and remove them one by one. This way is quite annoying and complex. If we can remove all hidden worksheets by only one step or a simple way, it will be much better. So, this article will help you to solve this issue. I will provide you two ways to remove all hidden worksheets conveniently. Please read the article below, let’s get started.
Delete/Remove Hidden Worksheets by VBA
Edit VBA script can help you to remove all worksheets in one workbook properly. So, this method is very helpful. You can copy below code directly.
Step 1: On current visible worksheet, right click on sheet name tab to load Sheet management menu. Select View Code, Microsoft Visual Basic for Applications window pops up.
Or you can enter Microsoft Visual Basic for Applications window via Developer->Visual Basic.
Step 2: In Microsoft Visual Basic for Applications window, click Insert->Module, enter below code in Module1:
Sub RemoveAllHiddenSheets() Dim i As Integer Application.DisplayAlerts = False For Each sht In ActiveWorkbook.Sheets If sht.Visible = xlSheetHidden Then sht.Delete i = i + 1 End If Next sht Application.DisplayAlerts = True End Sub
Step 3: Save the codes, see screenshot below. And then quit Microsoft Visual Basic for Applications.
Step 4: Before run macro, let’s see if there are unhide worksheets exist in this workbook.
Unhide is enabled in menu so there are some hidden worksheets in this workbook.
Step 5: On current sheet, click Developer->Macro, in Macro window, select Macro ‘RemoveAllHiddenSheets’, then click Run.
Step 6: Check if the hidden worksheets are removed or not.
Unhide is disabled so there is no hidden worksheet now.
- If you want to get some message when running macro to delete hidden worksheets, you can add below code into module. Then you can get some message prompts when executing the macro.
If i = 1 Then MsgBox " sheet is removed from this workbook." Else MsgBox "[" & i & "] sheets are removed from this workbook." End If
- See the screenshot below:
- Run macro this time, verify that below message pops up to indicate that some sheets are removed.
Delete/Remove Hidden Worksheets by Inspect Document Function
This method is helpful for the users who are not skilled in code editing. And they can follow below steps to remove all hidden worksheets. All operations are conveniently to operate.
Step 1: In Excel ribbon, click File->Info->Check for Issues->Inspect Document.
Step 2: Click Yes on pops up message.
Step 3: On pops up Document Inspector, click Inspect.
Step 4: On current Document Inspector window, drag the scrollbar to the end, verify that Hidden Worksheets is listed, click Remove All.
Step 5: Verify that all hidden worksheets were removed. Then click Close.
Step 6: Right click on sheet name tab to double check, verify that Unhide is disabled in menu, that means there is no hidden worksheet now.