Delete Hidden Worksheets

Add to Favorites
Author:
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







Excel VBA Course

(35% Sale Ends Jan. 26)

Excel VBA Course - From Beginner to Expert

200+ Video Lessons 50+ Hours of Instruction 200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course (35% Discount)

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...
Require a Password to View Hidden Worksheets in Excel - VBA Tutorial
Tutorial: Full Course A simple macro that allows you to require a password in order to view hidden ...
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 char...
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. The ...
Create an Index / Table of Contents worksheet
: To create an Index / Table of Contents worksheet to a workbook: 1) Add a new worksheet and...


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.

Tutorial Details
Similar Content
Delete Hidden Rows in a Workbook
Macro: This macro will delete hidden rows from every worksheet in an entire workbook. However...
Require a Password to View Hidden Worksheets in Excel - VBA Tutorial
Tutorial: Full Course A simple macro that allows you to require a password in order to view hidden ...
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 char...
Excel VBA Course

(35% Sale Ends Jan. 26)

Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course (35% Discount)