Delete Hidden Worksheets

Add to Favorites
This macro will delete all hidden worksheets within a workbook. When you run this macro a warning window will pop up for each hidden sheet making sure that you want to delete it. This is a precaution which Microsoft Excel takes and not the actually macro itself. Though, this is good because it makes sure you think twice before deleting something that could have necessary or valuable information contained within it.

Where to install the macro:  Module

Delete Hidden Worksheets

Sub DeleteHiddenWorksheets()

'This Macro will remove all hidden worksheets from a workbook.
'There will be a warning window that pops up to make sure you want
'to do this just in case there is other information that is needed
'within those hidden sheets.

i = 1
While i <= Worksheets.Count
If Not Worksheets(i).Visible Then
Worksheets(i).Delete
Else
i = i + 1
End If
Wend

End Sub







Similar Content on TeachExcel
Delete Hidden Rows in a Workbook
Macro: This macro will delete hidden rows from every worksheet in an entire workbook. However...
Delete All Chart Sheets in Excel - Only Chart Sheets are Deleted - Not Embedded Charts
Macro: Delete all chart sheets and tabs in Excel using this macro. This will only delete the...
Hide Data Within a Worksheet in Excel
Tutorial: In Excel you can actually hide data that is stored within a worksheet. This allows you to ...
Hide Formulas in a Worksheet and Prevent Deletion
Macro: This macro will hide all formulas within a workbook and not allow them to be deleted. ...
Delete Duplicate Values in All Versions of Excel
Tutorial: How to delete duplicate values from a data set in all versions of Excel.  This includes Ex...
Delete All Rows that Contain a Specific Value in Excel
Tutorial: Quickly find all rows in Excel that contain a certain value and then delete those rows. ...



How to Install the Macro
  1. Select and copy the text from within the grey box above.

  2. Open the Microsoft Excel file in which you would like the Macro to function.

  3. Press "Alt + F11" - This will open the Visual Basic Editor - Works for all Excel Versions.  Or For other ways to get there, Click Here.

  4. On the new window that opens up, go to the left side where the vertical pane is located. Locate your Excel file; it will be called VBAProject (YOUR FILE'S NAME HERE) and click this.

  5. If the Macro goes in a Module, Click Here, otherwise continue to Step 8.

  6. If the Macro goes in the Workbook or ThisWorkbook, Click Here, otherwise continue to Step 8.

  7. If the Macro goes in the Worksheet Code, Click Here, otherwise continue to Step 8.

  8. Close the Microsoft Visual Basic Editor window and save the Excel file. When you close the Visual Basic Editor window, the regular Excel window will not close.

  9. You are now ready to run the macro.


Similar Content
Delete Hidden Rows in a Workbook
Macro: This macro will delete hidden rows from every worksheet in an entire workbook. However...
Delete All Chart Sheets in Excel - Only Chart Sheets are Deleted - Not Embedded Charts
Macro: Delete all chart sheets and tabs in Excel using this macro. This will only delete the...
Hide Data Within a Worksheet in Excel
Tutorial: In Excel you can actually hide data that is stored within a worksheet. This allows you to ...
Excel Forum