Excel VBA Hidden Worksheets: Hide and Unhide Sheets

VBA & macros · Updated November 21, 2026

In Excel VBA, hide a worksheet by setting its Visible property to xlSheetHidden or xlSheetVeryHidden; set it to xlSheetVisible to show it again. A VeryHidden sheet cannot be restored through Excel’s ordinary Unhide dialog, but it is still part of the workbook and can be revealed in VBA or the Visual Basic Editor.

What Hidden and VeryHidden mean

Excel has three visibility states for a worksheet. xlSheetVisible means the sheet appears as a tab. xlSheetHidden removes the tab but allows a user to restore it through Excel’s Unhide command. xlSheetVeryHidden also removes the tab, but excludes the sheet from that dialog. The difference is a matter of discoverability and control, not a difference in whether the sheet’s contents still exist.

These are values of the worksheet’s Visible property, rather than separate types of worksheet. A hidden worksheet can still be referenced by formulas and VBA, and its cells remain in the workbook. Hiding a sheet does not encrypt its contents or make confidential information safe from someone who can inspect the file.

In the VBA editor, the property values are commonly displayed as -1 - xlSheetVisible, 0 - xlSheetHidden, and 2 - xlSheetVeryHidden. In code, use the named constants for readability instead of relying on the numbers.

Hide a worksheet with VBA

The following macro hides a worksheet called Report as VeryHidden. It assumes a sheet called Dashboard exists and is visible; Excel cannot hide the active worksheet, so the macro activates Dashboard first if Report is currently active. Change the sheet names to match the workbook. The code belongs in a standard VBA module, which you can add in the Visual Basic Editor with Insert > Module.

Sub HideReport()
    Dim ws As Worksheet

    ' Make sure the sheet to hide is not active.
    Set ws = ThisWorkbook.Worksheets("Report")
    If ws Is ActiveSheet Then
        ThisWorkbook.Worksheets("Dashboard").Activate
    End If

    ' Remove the Report tab from the Unhide dialog too.
    ws.Visible = xlSheetVeryHidden
End Sub

To make the sheet ordinarily hidden instead, replace the last line with ws.Visible = xlSheetHidden. Use ThisWorkbook when the macro is stored in the workbook it should change. This avoids accidentally targeting whichever workbook happens to be active. If the macro is stored in Personal.xlsb or an add-in, use an explicit workbook reference appropriate to that setup rather than assuming ThisWorkbook is the file being edited.

Before running a macro, save a copy of the workbook. VBA changes cannot be reversed with Ctrl+Z, and hiding or unhiding a sheet is not an undoable action. In Excel for Microsoft 365 on Windows, Alt+F11 opens the Visual Basic Editor; on Mac, the equivalent shortcut is generally Option+F11, sometimes with Fn depending on the keyboard. Excel for the web does not run VBA macros.

Unhide one sheet with VBA

To restore a VeryHidden or ordinarily hidden worksheet, assign xlSheetVisible. This example reveals the sheet named Report in the workbook containing the macro:

Sub ShowReport()
    Dim ws As Worksheet

    ' Restore the worksheet tab.
    Set ws = ThisWorkbook.Worksheets("Report")
    ws.Visible = xlSheetVisible
End Sub

If you are not sure whether a sheet is hidden or VeryHidden, this assignment works for either state. The name must match the worksheet tab name exactly; if there is no sheet named Report, VBA raises an error. For a one-time change, you can also select the sheet in the editor and change its Visible property in the Properties window. That is useful when you can access the VBA project but do not need a reusable macro.

Unhide sheets through Excel’s interface

For a normally hidden worksheet, use Excel’s built-in command rather than VBA when that is all you need. In Excel for Microsoft 365 on Windows, right-click any visible sheet tab, choose Unhide, select a sheet, and choose OK. You can also use Home > Format > Hide & Unhide > Unhide Sheet. Excel’s dialog restores one selected sheet at a time.

If the sheet is VeryHidden, it will not appear in the Unhide dialog. Change its Visible property to xlSheetVisible in VBA or the Visual Basic Editor instead. A macro is convenient if the same action is part of a regular workflow; the interface is simpler for occasional changes. Excel for Mac has different ribbon and context-menu layouts, but the underlying distinction between Hidden and VeryHidden is the same in desktop Excel. Excel for the web cannot run VBA to change the property.

Choose the right visibility setting

Use ordinary Hidden when users may reasonably need to restore a support sheet themselves. Use VeryHidden when a workbook’s intended interface should not offer that sheet in the standard Unhide dialog—for example, a workbook might keep a configuration or lookup sheet out of the way while a macro uses its values. Leave a sheet visible when people need to view or edit it during routine use.

Consider these practical factors before choosing:

  • Who needs access? A hidden tab can be restored by a user who knows the Unhide command. VeryHidden requires access to VBA or the editor.
  • How often will the sheet change? If staff must frequently edit its content, hiding it may make maintenance harder and increase the chance of confusion.
  • Is the sheet a user interface or a storage area? A supporting sheet may be a sensible candidate for hiding, but hiding should not be treated as a security boundary.
  • Will the workbook be shared? Explain how authorized users can reveal or maintain hidden content, especially if the workbook will be handed to another team.

A common misconception is that VeryHidden protects formulas, prices, or personal data. It only removes a convenient route to the tab. Someone with sufficient access to the workbook may still inspect its contents or the VBA project. Do not store secrets in a workbook just because the relevant sheet is hidden.

Workbook structure protection and other protections

Worksheet protection and workbook structure protection solve different problems. Protect Sheet limits certain edits to cells and worksheet features; it does not determine whether the sheet tab is visible. Protect Workbook structure restricts actions such as adding, deleting, moving, renaming, hiding, and unhiding sheets through the Excel interface. It is separate from protecting the worksheet’s cells.

If a workbook’s structure is protected, Excel may prevent visibility changes, and a macro that tries to change a sheet’s Visible property may fail until the structure is unprotected. A password used for workbook protection should not be confused with encryption or a guarantee that data is secure against inspection. If you inherit a protected workbook, follow its owner’s approved process; do not assume that hiding a sheet or changing a property is an appropriate way around protection.

Common problems and checks

If a macro errors when hiding a sheet, check that its name is correct, that the workbook structure allows the change, and that another visible sheet remains active. Excel requires at least one visible sheet in a workbook, so code cannot leave every worksheet hidden. The example macro activates Dashboard before hiding Report for that reason; Dashboard must exist and be visible.

If the sheet is missing from the Unhide dialog, it may be VeryHidden rather than deleted. Check the workbook’s sheet list in the Visual Basic Editor and inspect the worksheet’s Visible property. If the VBA project is locked or inaccessible, you may need to contact the workbook’s author or administrator. A sheet can also be present but overlooked among many tabs, so check the workbook’s sheet names before concluding it has disappeared.

When code changes the wrong workbook, qualify the sheet reference. ActiveWorkbook means the workbook currently in focus; ThisWorkbook means the workbook containing the running code. That distinction matters when a macro is launched from the Personal Macro Workbook or an add-in. Also remember that Worksheets refers to worksheet tabs, whereas Sheets can include chart sheets as well. If the tab is a chart sheet, declare and reference it as a chart sheet or use the broader Sheets collection as appropriate.

Frequently Asked Questions

How do I hide a worksheet in Excel VBA? Set its Visible property to xlSheetHidden for a sheet that users can restore through Unhide, or xlSheetVeryHidden to remove it from that dialog. Activate a different visible sheet first if the target is active.

How do I unhide a VeryHidden sheet? In VBA, refer to the worksheet by its exact name and set Visible to xlSheetVisible. You can also select it in the Visual Basic Editor and change its Visible property. It will then appear as a tab.

Can I unhide every worksheet with a macro? Yes, but first save a copy and consider whether exposing every support sheet is appropriate. This code makes all worksheets in the workbook containing the macro visible:

Sub ShowAllWorksheets()
    Dim ws As Worksheet

    ' Reveal every worksheet in this workbook.
    For Each ws In ThisWorkbook.Worksheets
        ws.Visible = xlSheetVisible
    Next ws
End Sub

This does not target chart sheets, and it can fail if workbook structure protection prevents visibility changes. It may also reveal sheets users were not meant to see in the normal interface.

Can a hidden worksheet still be used in formulas? Yes. Hiding a worksheet does not remove its cells, formulas, or references. A formula on a visible sheet can continue to refer to cells on a hidden worksheet.

Can I run VBA to unhide a sheet in Excel for the web? No. Excel for the web does not run VBA macros or provide the desktop Visual Basic Editor. Open the workbook in desktop Excel to use VBA; ordinary hidden sheets may also be manageable through available web interface commands, but VeryHidden requires desktop VBA access to change that property.

Related

Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.

More in VBA & macros

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.