If you want to unhide all Worksheets in a Workbook at once, this simple macro makes easy work for you.
Unhide All Worksheets in a Workbook
'---------------- Modules ----------------
Sub UnhideAllWorksheets()
'Step 1: Declare your variables
Dim ws As Worksheet
'Step 2: Start looping through all worksheets
For Each ws In ActiveWorkbook.Worksheets
'Step 3: Loop to next worksheet
ws.Visible = xlSheetVisible
Next ws
End Sub
How This Macro Works
- In Step 1 declares an object called ws. This creates a memory container for each worksheet the macro loops through.
- In Step 2, the macro starts the looping, telling Excel to enumerate through all worksheets in this workbook.
- In Step 3 changes the visible state to xlSheetVisible. Then it loops back to get the next worksheet.
How to Use This Macro
Most VBA code should be placed in Standard Modules unless specified.
If you see a comment '------------------ Modules------------------
in the code header that means put the code in a Standard Module. For more information, learn this course: Where should I put the Excel VBA code?
The following steps teach you how to put VBA code into a Standard Module:
- Activate the Visual Basic Editor by pressing ALT + F11.
- Right-click the project/workbook name in the Project Window.
- Choose Insert -> Module.
- Type or paste the code in the newly created module. You will probably need to change the sheet name, the range address, and the save location.
- Click Run button on the Visual Basic Editor toolbar.
- For more information, learn this course: Programming with Excel VBA