Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Excel VBA: Unhide All Sheets in a Workbook

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To unhide every sheet in an Excel workbook with VBA, open the Visual Basic Editor (Alt+F11), insert a new module, and run a short macro that loops through the Sheets collection setting each sheet's Visible property to xlSheetVisible. The core line is For Each ws In ThisWorkbook.Sheets: ws.Visible = xlSheetVisible: Next ws. This works for worksheets, chart sheets, and dialog sheets, and it also reveals sheets hidden with xlSheetHidden or xlSheetVeryHidden. You need the workbook open and macros enabled; if the project is password-protected you will need that password.

What You'll Need

  • Excel for Windows or Mac with the workbook open.
  • Macros enabled for the file (or the ability to enable them when prompted).
  • The VBA project password, if one is set.
  • Basic familiarity with the Visual Basic Editor (VBE).

Step-by-Step

  1. Open the workbook that contains the hidden sheets. If the file is in a trusted location or you trust the source, enable macros when Excel asks.
  2. Open the Visual Basic Editor with Alt+F11 (Windows) or Fn+Alt+F11 (some Mac keyboards). On Mac you can also use Tools > Macro > Visual Basic Editor from the Excel menu.
  3. Insert a standard module: in the VBE choose Insert > Module. A blank code window appears.
  4. Paste the macro below into the module. It uses ThisWorkbook so it acts on the workbook that contains the code, not whatever workbook happens to be active.
Sub UnhideAllSheets()
    Dim ws As Object
    For Each ws In ThisWorkbook.Sheets
        ws.Visible = xlSheetVisible
    Next ws
End Sub
  1. Run the macro: place the cursor inside the subroutine and press F5, or use Run > Run Sub/UserForm. You can also close the VBE and press Alt+F8, select UnhideAllSheets, and click Run.
  2. Verify the result: return to Excel and check the sheet tabs. Every previously hidden sheet should now be visible. If a sheet still does not appear, see Troubleshooting below.
  3. Save the workbook as .xlsm if you want to keep the macro for next time. A normal .xlsx save will strip the VBA code.

Labels in the VBE and on the ribbon can differ slightly by Excel version, platform, and region, but the Insert > Module path and the Visible property are stable across current versions.

Common Mistakes

  • Using ActiveWorkbook instead of ThisWorkbook. If another workbook is active when the macro runs, ActiveWorkbook points at the wrong file. ThisWorkbook always refers to the workbook holding the code.
  • Looping only Worksheets. The Worksheets collection excludes chart sheets. Use Sheets (as above) to cover every sheet type.
  • Forgetting xlSheetVisible. Assigning True or 1 may work in some contexts but is less clear; the named constant is the reliable choice.
  • Saving as .xlsx. The macro disappears on save. Use .xlsm.
  • Assuming a protected workbook will cooperate. If the workbook structure is protected, the Visible property change fails until you unprotect it (Review > Protect Workbook).
  • Expecting the macro to reveal sheets in a different file. It only touches ThisWorkbook. Open the other file and put the macro there, or modify the code to reference that workbook explicitly.

Tips

  • Add a companion macro that hides all but the active sheet, so you can toggle visibility quickly during reviews.
  • Use ws.Visible = xlSheetVeryHidden when you want a sheet hidden from the normal right-click Unhide menu; the same loop with xlSheetVisible brings it back.
  • Store the macro in your Personal Macro Workbook if you want it available in every Excel session. In the VBE, find PERSONAL.XLSB in the Project Explorer; if it does not exist, record a dummy macro and choose Personal Macro Workbook as the store location.
  • Before running any bulk visibility change, save a copy of the workbook. Visibility changes are easy to reverse, but a backup protects against accidental edits in the same session.
  • If you share the file, note that hidden and very hidden sheets are not a security feature; anyone with the password or macro access can reveal them.

Troubleshooting

  • Macro does not run. Check that macros are enabled and the file is not blocked. In Windows, right-click the file > Properties and look for an Unblock checkbox; if present, tick it and reopen.
  • Run-time error 1004. This usually means the workbook structure is protected. Unprotect via Review > Protect Workbook (you will need the password), then rerun.
  • Sheet still hidden after running. The sheet may be in a different workbook, or the workbook may have been saved with the sheet very hidden and the macro run against the wrong file. Confirm ThisWorkbook is the file you think it is by adding Debug.Print ThisWorkbook.FullName before the loop and checking the Immediate Window (Ctrl+G).
  • VBE will not open. The VBA project may be password-protected; you need the password to view or edit the code. If you do not have it, ask the file's author.
  • Macro vanishes after saving. The file was saved as .xlsx. Use File > Save As and choose Excel Macro-Enabled Workbook (.xlsm).
  • Only some sheets appear. Chart sheets and dialog sheets are included by the Sheets collection but not by Worksheets. If you used Worksheets, switch to Sheets.

Frequently Asked Questions

Does this unhide very hidden sheets too?

Yes. Setting Visible to xlSheetVisible reveals sheets hidden with xlSheetHidden and xlSheetVeryHidden alike.

Can I unhide sheets without VBA?

For normally hidden sheets, right-click any tab and choose Unhide. Very hidden sheets do not appear in that dialog, so VBA (or the VBE Properties window) is the practical route.

Will this work on Excel for Mac?

Yes, the VBA object model and the Visible property are the same. Keyboard shortcuts for the VBE may differ slightly by keyboard layout.

Why does the macro fail with a password-protected workbook?

Workbook structure protection blocks visibility changes. Unprotect the workbook first, run the macro, then re-protect if needed.

Can I run this on a workbook I have not opened?

No. VBA can only change sheets in an open workbook. Open the file first, then run a macro that references it by name or uses ThisWorkbook from within that file.

Does unhiding sheets affect formulas or links?

No. Visibility is a display property; formulas, named ranges, and external links continue to work as before.