Excel VBA: Unhide Named Ranges Step by Step
In this article
A hidden named range in Excel is a defined name whose Visible property has been set to False, so it no longer appears in the Name Box drop-down or the Name Manager list. To unhide it with VBA, loop through ThisWorkbook.Names, set nm.Visible = True, and optionally set the name's RefersTo cell range visible too. The code is four lines long, but the practical part is knowing the difference between a hidden name and hidden rows or columns, and dealing with the added layer of Visible scope on worksheets. This guide walks through the macro, a version that skips broken names, and the fixes for the usual failures.
What You'll Need
- Excel on Windows or Mac with the Developer tab enabled (File > Options > Customize Ribbon > check Developer; on Mac, Excel > Preferences > Ribbon & Toolbar).
- A workbook that actually contains hidden defined names. Hidden names are often created by add-ins, by pasting from other workbooks, or by macros that used
Visible = False. - Macro security set to allow macros, or the file saved as
.xlsmor.xlsbso the code persists. A plain.xlsxdiscards VBA when saved. - Permission to modify the workbook. If it is shared or protected, unshare or unprotect it first, or the macro will error.
Menu labels in Excel vary slightly by version, platform and region, so if a path looks different, look for the closest matching option.
Step-by-Step
- Make a copy first. Save a duplicate of the workbook before running any macro that rewrites names. Unhiding a name is normally harmless, but if a name was hidden deliberately by an add-in, revealing it can clutter the Name Box with hundreds of internal entries.
- Open the VBA editor. Press
Alt + F11on Windows. On Mac, useOption + F11(or Developer > Visual Basic). The editor opens in its own window. - Insert a module. In the editor, go to Insert > Module. A blank code pane appears. You can also put the code in a standard module rather than a sheet module, which makes it easier to run from anywhere.
- Paste the basic unhide loop. This is the shortest working version:
It handles workbook-level names in one pass and costs almost nothing to run.Sub UnhideAllNames() Dim nm As Name For Each nm In ThisWorkbook.Names nm.Visible = True Next nm End Sub - Add worksheet-level names. Names scoped to a single sheet are stored in the same collection but behave differently. To be thorough, loop the sheets as well:
In practice the workbook loop usually reaches sheet-scoped names too, but the second loop makes the intent explicit and catches odd cases.Sub UnhideAllNamesDeep() Dim nm As Name Dim ws As Worksheet For Each nm In ThisWorkbook.Names nm.Visible = True Next nm For Each ws In ThisWorkbook.Worksheets For Each nm In ws.Names nm.Visible = True Next nm Next ws End Sub - Guard against broken names. A name whose formula refers to a deleted sheet raises an error when you touch it. Wrap the assignment:
The Immediate window (Ctrl + G) then lists any names that could not be fixed, which tells you which ones refer to missing sheets and need deleting or redefining.Sub UnhideNamesSafely() Dim nm As Name For Each nm In ThisWorkbook.Names On Error Resume Next nm.Visible = True If Err.Number <> 0 Then Debug.Print "Skipped: " & nm.Name & " - " & Err.Description Err.Clear End If On Error GoTo 0 Next nm End Sub - Run the macro. With the cursor inside the procedure, press
F5, or use Run > Run Sub/UserForm. Alternatively, go back to Excel, pressAlt + F8, select the macro name and click Run. - Verify the result. Return to Excel and open Formulas > Name Manager (
Ctrl + F3). The list should now show every name. Click the Name Box drop-down on the left of the formula bar to confirm the names appear there as well. - Reveal the underlying cells if needed. A hidden name is not the same as hidden rows or columns. If the goal is to see the cells the name points to, select the name and run
Range(nm.Name).EntireRow.Hidden = Falseand the column equivalent, or useRows.Hidden = Falseon the named area. For a single name, the easiest route is to type the name in the Name Box, press Enter, then use Format > Hide & Unhide > Unhide Rows and Columns. - Save as a macro-enabled file. Use File > Save As and pick
.xlsm. If you only need to unhide names once, you can delete the module afterwards and save as.xlsxagain once the change is done.
Common Mistakes
- Confusing hidden names with hidden rows. Setting
Visible = Trueon a name does not unhide any rows or columns. The two properties are unrelated, and fixing one often leaves the visible symptom untouched. - Using
ActiveWorkbookinstead ofThisWorkbook. If another workbook has focus,ActiveWorkbookpoints at the wrong file and the macro edits the wrong set of names. - Looping
Workbook.Nameswith a For...Next index while unhiding. Revealing names can reorder or resize the collection and cause names to be skipped. UseFor Each, which copes with collection changes better. - Forgetting protected workbooks. If the workbook structure is protected, you get a runtime error on the assignment. Unprotect the workbook (Review > Protect Workbook) first.
- Expecting names created by add-ins to disappear. Many add-ins create hidden names intentionally, and unhiding them makes the Name Box unwieldy. If you only need your own names, unhide selectively rather than in bulk.
- Assuming a macro-enabled save happened. Saving over an
.xlsxsilently drops the module. Check the title bar for the.xlsmextension.
Tips
- Build a selective version that matches a name prefix, for example
If InStr(nm.Name, "MyPrefix") > 0 Then nm.Visible = True, so you do not flood the Name Box with add-in names. - Use
Debug.Print nm.Nameinside the loop first, running with the Immediate window open, to see exactly what is in the collection before changing anything. - To hide names again later, set
Visible = Falsein the same loop. Keeping a short hide/unhide pair in a personal macro workbook is a quick way to toggle them back and forth. - A name that shows as
#REF!in Name Manager cannot be unhidden usefully. Delete it (Formulas > Name Manager > Delete) unless you know why it exists. - If you run this often, add the macro to the Quick Access Toolbar (File > Options > Quick Access Toolbar) rather than opening the VBA editor each time.
Troubleshooting
The macro runs but names still do not show. Check that you are looking at the same workbook, and that the names are not scoped to a different sheet. In Name Manager, look at the Scope column; sheet-scoped names only appear when that sheet is active. The deep version of the loop above handles this.
Run-time error 1004. Usually an invalid or broken reference inside a name, or a protected workbook. Run the safe version with On Error Resume Next and inspect the Immediate window output to identify the offending name.
"Sub or Function not defined". The code was pasted into a sheet or workbook module but called from a different place, or a typo in the procedure name. Put helpers in a standard module and check the exact name used by Alt + F8.
Nothing happens at all. Macros are likely disabled. Check the yellow security bar under the ribbon, or File > Options > Trust Center > Trust Center Settings > Macro Settings, and enable macros for the file. Never lower macro security for files from unknown sources.
Names are visible but the cells are still hidden. That is expected. Apply the row and column unhide step separately, and remember that grouped outlines can re-hide rows the moment you collapse them.
If that did not work, copy the workbook, strip the VBA, and rebuild only the names you actually need in Formulas > Name Manager > New. For a handful of names this is faster and safer than debugging a large, add-in-contaminated set.
Frequently Asked Questions
What is a hidden named range?
It is a defined name whose Visible property is set to False. The name and its reference still exist and still work in formulas; it is simply filtered out of the Name Box and Name Manager list.
Can I unhide named ranges without VBA?
Excel has no built-in menu command for revealing a hidden name. VBA is the reliable route, though third-party add-ins can do it too. A macro is the simplest option for most users.
Does unhiding a name unhide rows or columns?
No. The name's visibility is independent of worksheet row and column visibility. Unhide the cells separately with Format > Hide & Unhide.
Why are sheet-scoped names still missing?
Sheet-scoped names only appear in Name Manager while that sheet is active, and some are created hidden by add-ins. Loop Worksheet.Names or activate each sheet before checking.
Will this change formulas or break my model?
Changing visibility does not alter the name's reference, so formulas that use the name keep working. Broken names pointing at deleted sheets are the real risk, which is why the safe loop skips and reports them.
How do I hide them again?
Run the same loop with nm.Visible = False. Keep both macros in a personal workbook if you need to toggle frequently.