VBA & Macro Problems

Excel VBA: Unhide All Worksheets with the Visible Property

Anum MushtaqAnum Mushtaq Nov 27, 2026 869 views

Question details

Unhide every worksheet in an Excel workbook without constructing worksheet names in VBA.

Unhide All Excel Worksheets Using 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.
Before you start

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.

Solution 1Recommended

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.

1
Open the VBA editor

In Excel, open Developer > Visual Basic, or press Alt+F11 where supported.

2
Insert a module

In the VBA editor, select the target workbook in Project Explorer, then choose Insert > Module.

3
Add the macro

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

4
Run the macro

Place the cursor inside the macro and choose Run > Run Sub/UserForm, or press F5. Return to Excel to check the worksheet tabs.

Loop through the Worksheets collection
Hidden and very hidden sheets: The loop makes both hidden and very hidden worksheets visible. It does not change chart sheets.
Free Microsoft Office alternative

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.

Open and edit spreadsheets with a familiar worksheet interfaceCompatible with common Microsoft Excel formats, including XLSX and XLSFree and lightweight for everyday spreadsheet workMove existing Excel files into an easy-to-use office suite
microsoft office alternative - wps office

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.