Smart Systems for Home

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

Excel VBA: Unhide Named Ranges Step by Step

· 7 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

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 .xlsm or .xlsb so the code persists. A plain .xlsx discards 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

  1. 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.
  2. Open the VBA editor. Press Alt + F11 on Windows. On Mac, use Option + F11 (or Developer > Visual Basic). The editor opens in its own window.
  3. 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.
  4. Paste the basic unhide loop. This is the shortest working version:
    Sub UnhideAllNames()
        Dim nm As Name
        For Each nm In ThisWorkbook.Names
            nm.Visible = True
        Next nm
    End Sub
    It handles workbook-level names in one pass and costs almost nothing to run.
  5. 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:
    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
    In practice the workbook loop usually reaches sheet-scoped names too, but the second loop makes the intent explicit and catches odd cases.
  6. Guard against broken names. A name whose formula refers to a deleted sheet raises an error when you touch it. Wrap the assignment:
    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
    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.
  7. Run the macro. With the cursor inside the procedure, press F5, or use Run > Run Sub/UserForm. Alternatively, go back to Excel, press Alt + F8, select the macro name and click Run.
  8. 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.
  9. 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 = False and the column equivalent, or use Rows.Hidden = False on 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.
  10. 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 .xlsx again once the change is done.

Common Mistakes

  • Confusing hidden names with hidden rows. Setting Visible = True on a name does not unhide any rows or columns. The two properties are unrelated, and fixing one often leaves the visible symptom untouched.
  • Using ActiveWorkbook instead of ThisWorkbook. If another workbook has focus, ActiveWorkbook points at the wrong file and the macro edits the wrong set of names.
  • Looping Workbook.Names with a For...Next index while unhiding. Revealing names can reorder or resize the collection and cause names to be skipped. Use For 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 .xlsx silently drops the module. Check the title bar for the .xlsm extension.

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.Name inside 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 = False in 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.