Excel VBA Unhide Tab: How to Show Hidden Sheets
In this article
To unhide a tab using Excel VBA, you use the .Visible property of the Worksheet object, setting it to xlSheetVisible. This is the fastest way to reveal sheets that are either hidden or "Very Hidden," the latter of which cannot be unhidden through the standard Excel right-click menu. By writing a simple macro, you can unhide one specific sheet by name or create a loop that reveals every hidden tab in your entire workbook with a single click.
What You'll Need
- A computer with Microsoft Excel installed (Windows or macOS).
- A workbook containing one or more hidden or very hidden sheets.
- The Developer tab enabled in the Excel Ribbon (though you can also use the Alt+F11 shortcut).
- Basic access to the VBA Editor.
Step-by-Step
- Open the VBA Editor: Open your Excel workbook. Press
Alt + F11on your keyboard. This is the universal shortcut to launch the Visual Basic for Applications (VBA) editor. If you are on a Mac, you may need to useOption + F11or enable the Developer tab in the Ribbon and click the "Visual Basic" button. - Insert a New Module: Once the VBA editor is open, look at the Project Explorer window on the left side. Right-click on your workbook name (e.g.,
VBAProject (Book1)), hover overInsert, and selectModule. This creates a blank space where you can write your code without interfering with the sheet-specific code. - Write the Code to Unhide a Single Sheet: If you know the exact name of the tab you want to reveal, type the following code into the module window:
Sub UnhideSpecificSheet() Sheets("SheetName").Visible = xlSheetVisible End SubReplace"SheetName"with the actual name of your tab, keeping the quotation marks. - Write the Code to Unhide All Sheets: If you have many hidden tabs and don't want to unhide them one by one, use a "For Each" loop. Type this code into the module:
Sub UnhideAllSheets() Dim ws As Worksheet For Each ws In ThisWorkbook.Worksheets ws.Visible = xlSheetVisible Next ws End SubThis script tells Excel to look at every single worksheet in the current file and change its visibility status to visible. - Run the Macro: You can run the code directly from the VBA editor by clicking inside the subroutine (the code between
SubandEnd Sub) and pressingF5or clicking the green "Play" icon in the toolbar. - Return to Excel: Close the VBA editor window or press
Alt + Qto return to your spreadsheet. You will see that the previously hidden tabs are now visible at the bottom of your screen. - Save the Workbook Correctly: Because your file now contains a macro, you cannot save it as a standard
.xlsxfile. Go toFile > Save Asand selectExcel Macro-Enabled Workbook (.xlsm)from the dropdown menu. If you save it as a standard workbook, the VBA code will be deleted.
Common Mistakes
One of the most frequent errors is a Typo in the Sheet Name. VBA is very strict; if your tab is named "Data Sheet" but your code says Sheets("DataSheet"), Excel will trigger a "Subscript out of range" error. Always double-check that the spelling and spacing in your code match the tab name exactly.
Another common mistake is forgetting the file extension. Many users write a perfect script, save the file as a regular .xlsx, and then find the macro gone the next time they open the file. Always use .xlsm or .xlsb for files containing VBA.
Users also often confuse Workbook vs. Worksheet. If you try to apply the .Visible property to the Workbook object instead of the Worksheet object, the code will fail. Ensure your loop specifically targets ThisWorkbook.Worksheets.
Finally, some attempt to unhide sheets while the Workbook is Protected. If the workbook structure is locked via the "Protect Workbook" feature in the Review tab, VBA cannot change the visibility of sheets. You must unprotect the workbook first, either manually or via code, before the unhide command will work.
Tips
Dealing with "Very Hidden" Sheets: In Excel, there are two levels of hiding. A "Hidden" sheet can be unhidden by right-clicking a tab. A "Very Hidden" sheet (set via xlSheetVeryHidden) is invisible to the average user and cannot be seen in the right-click menu. The VBA method described above is the only way to reveal these sheets without manually changing the property in the VBA Properties window.
Creating a Toggle Button: Instead of opening the VBA editor every time, you can insert a button on your main sheet. Go to the Developer tab, click Insert, choose the Button (Form Control), and draw it on your sheet. Excel will then ask you which macro to assign to the button. Select UnhideAllSheets, and now you have a one-click solution for your users.
Using Code Names: If you think you or another user might rename the tabs, using Sheets("Name") will break the code. Instead, use the sheet's Code Name. In the VBA Project Explorer, you will see Sheet1 (Data). Here, Sheet1 is the Code Name and (Data) is the tab name. If you use Sheet1.Visible = xlSheetVisible, the code will work even if someone changes the tab name to "Archive".
Troubleshooting
Error: "Subscript out of range"
This almost always means Excel cannot find the sheet name you specified. Check for leading or trailing spaces in the tab name. For example, a tab named "Sales " (with a space at the end) is different from "Sales". To fix this, rename the tab manually to ensure there are no hidden spaces, or update the code to match exactly.
Error: "Unable to set the Visible property of the Worksheet class"
This usually happens because of Workbook Protection. Go to the Review tab and check if Protect Workbook is highlighted. If it is, click it to disable protection. If the workbook is password protected, you will need to enter the password before the VBA script can modify the sheet visibility.
The Macro Runs but Nothing Happens
Check if you are running the correct macro. If you have multiple subroutines in one module, ensure the cursor is inside the UnhideAllSheets block before pressing F5. Also, verify that the sheets actually exist in the workbook; if the workbook is empty or the sheets were deleted, the loop will complete without making any visible changes.
VBA Editor is Greyed Out or Missing
If you cannot access the VBA editor, your company may have disabled macros via Group Policy for security reasons. Check with your IT administrator to see if macros are permitted. If you are the administrator, go to File > Options > Trust Center > Trust Center Settings > Macro Settings and select "Disable VBA macros with notification" to allow them to be enabled on a case-by-case basis.
Frequently Asked Questions
Can I unhide all sheets at once without VBA?
No, the standard Excel interface only allows you to unhide one sheet at a time through the right-click menu. To unhide multiple sheets simultaneously, you must use a VBA macro or a third-party add-in.
What is the difference between Hidden and Very Hidden?
A "Hidden" sheet can be revealed by any user via the right-click menu on the sheet tabs. A "Very Hidden" sheet is completely removed from that menu and can only be made visible through the VBA editor or a macro.
Will this VBA code work on Excel for Web?
No, VBA macros do not run in Excel for the Web (the browser version). You must open the file in the Excel Desktop Application to execute VBA code. For web-based automation, you would need to use Office Scripts (TypeScript).
Is it safe to run VBA code from the internet?
You should only run VBA code that you understand or that comes from a trusted source. Macros can potentially execute commands that delete files or modify data. Always review the code for any suspicious commands before running it in a production workbook.
Can I hide sheets using VBA as well?
Yes. To hide a sheet, use Sheets("SheetName").Visible = xlSheetHidden. To make it very hidden, use Sheets("SheetName").Visible = xlSheetVeryHidden.
Do I need to be a programmer to use this?
No. As long as you can copy and paste the code into the module and follow the steps to open the editor, you can use these macros without knowing how to write the code from scratch.