If you want to unhide all Worksheets in a Workbook at once, this simple macro makes easy work for you.
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
The best place to store this macro is in your Personal Macro Workbook. This way, the macro is always available to you. The Personal Macro Workbook is loaded whenever you start Excel. In the VBE Project window, it is named personal.xlsb.
- Activate the Visual Basic Editor by pressing ALT+F11.
- Right-click personal.xlsb in the Project window.
- Choose Insert ➜ Module.
- Type or paste the code in the newly created module.
Don't see personal.xlsb in your project window?
If you don't see personal.xlsb in your project window, it doesn’t exist yet. You’ll have to record a macro, using Personal Macro Workbook as the destination.
To record the macro in your Personal Macro Workbook, select the Personal Macro Workbook option in the Record Macro dialog box before you start recording. This option is in the Store Macro In drop-down box.
Simply record a couple of cell clicks and then stop recording. You can discard the recorded macro and replace it with this one.