Excel VBA: Unhide All Worksheets with the Visible Property
Question details
Unhide every worksheet in an Excel workbook without constructing worksheet names in VBA.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A user wants to set all worksheets in a workbook to visible using a VBA macro.
- Observed behavior
- Constructed names such as Sheet1 may not identify the intended worksheet when tab names or VBA code names differ.
Open the workbook in Excel and make sure you can access the VBA editor. If the workbook structure is protected, unprotect it using the password before changing worksheet visibility.
Loop through the Worksheets collection
Use a Worksheet variable to unhide every worksheet without depending on its tab name or code name.
ThisWorkbook refers to the workbook containing the macro. If the macro is stored elsewhere, explicitly target the workbook you want to change instead.
In Excel, open Developer > Visual Basic, or press Alt+F11 where supported.
In the VBA editor, select the target workbook in Project Explorer, then choose Insert > Module.
Paste this code into the module: Sub UnhideAllWorksheets() Dim ws As Worksheet For Each ws In ThisWorkbook.Worksheets ws.Visible = xlSheetVisible Next ws End Sub
Place the cursor inside the macro and choose Run > Run Sub/UserForm, or press F5. Return to Excel to check the worksheet tabs.

Unhide worksheets by index
Use a numeric loop if you prefer to access worksheets by their position in the collection.
Work with Excel spreadsheets in WPS Office
WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and Excel format support for a smoother move between office suites. VBA availability and macro behavior can vary by WPS version, so check compatibility before relying on an existing macro.

Frequently Asked Questions
Why does constructing a name like Sheet1 fail in VBA?
A worksheet's tab name and VBA code name are different identifiers. Concatenating text does not create a VBA object reference. Use a Worksheet variable in a For Each loop or access ThisWorkbook.Worksheets by index.
Will the macro unhide very hidden worksheets?
Yes. Setting each worksheet's Visible property to xlSheetVisible makes both normally hidden and very hidden worksheets visible.
What if the macro cannot change a sheet's visibility?
Check whether the workbook structure is protected. In Excel, use Review > Protect Workbook to unprotect the structure, entering the password if prompted, and then run the macro again.
How do I keep the macro in the workbook?
Use File > Save As and choose Excel Macro-Enabled Workbook (*.xlsm). Run macros only when you trust their source.




