Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Finding Unused Names.

Finding Unused Names

Written by Allen Wyatt (last updated March 30, 2019)
This tip applies to Excel 97, 2000, 2002, and 2003


5

Richard has a workbook that he's been using for a while, and it has quite a few names in it (named ranges, named formulas, etc.). He wonders if there is an easy way to find names that are not used at all, as he'd like to get rid of those names.

There is no built-in way to get rid of these unused names. You can, however, create a macro that will do the trick for you. This is most easily done by using the Find method to figure out which names have references that can be "found." If the reference cannot be found, then the name is not in use.

Sub RidOfNames()
    Dim myName As Name
    Dim fdMsg As String

    On Error Resume Next
    fdMsg = ""
    For Each myName In Names
        If Cells.Find(What:=myName.Name, _
          After:=ActiveCell, _
          LookIn:=xlFormulas, _
          LookAt:=xlPart, _
          SearchOrder:=xlByRows, _
          SearchDirection:=xlNext, _
          MatchCase:=False, _
          SearchFormat:=False).Activate = False Then
            fdMsg = fdMsg & myName.Name & vbCr
            ActiveWorkbook.Names(myName.Name).Delete
        End If
    Next myName
    If fdMsg = "" Then
        MsgBox "No unused names found in the workbook"
    Else
        MsgBox "Names Deleted:" & vbCr & fdMsg
    End If
End Sub

The macro steps through all the elements of the Names collection and does a search for each name. If the name cannot be found, then the name is deleted. When the macro is completed, it displays a message box that lists the names that were removed from the workbook.

If you would rather not create your own macro, you can opt to use a free add-in by Jan Karel Pieterse. The add-in, called Name Manager, allows you to (guess what?) manage names better than you can do with native Excel. One of the functions it provides is the ability to get rid of names that are no longer needed. You can find the add-in here:

http://www.jkp-ads.com/OfficeMarketPlaceNM-EN.asp

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (3312) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Finding Unused Names.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Pasting Text with Track Changes

Track Changes is a great tool for developing documents. If you want to copy text from one document to another, with ...

Discover More

Word Won't Capitalize Some Sentences

By default, Word capitalizes the first letter of sentences as you type. If you notice that Word doesn't capitalize some ...

Discover More

Changing from Absolute to Relative Hyperlinks

It is easy to amass a large number of hyperlinks in a document. You may want to process these hyperlinks in some way, ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (menu)

Entering the Current Time

Need to enter the current time into a cell? It's easy to do using this keyboard shortcut. The shortcut is a handy one to ...

Discover More

Noting When a Workbook was Changed

Do you need to know when a workbook was last changed? There are a couple of ways you can go about keeping track of the ...

Discover More

Referencing the Last Cell in a Column

When developing formulas, you may need to reference the very last value in a particular column. This can seem perplexing, ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 8 + 7?

2022-10-31 04:08:34

G

Seems to have work by me, having hundreds of irrelevant names from financial model consolidation. Thank you!!!


2020-07-23 11:35:14

Michel Goes

1. It must be noted that a named range can have the same name as a built-in Excel function. E.g. I can name my named range SUM i.e. exactly as the SUM function. So if a formula uses the SUM function but the SUM named range is not used anywhere in the worksheet/workbook, it is believed to be used while in fact it is not.
2. Another point is that a formula can contain a string literal which can potentially contain a string of characters matching the name of a defined named range. This also results this named range believed to be used while in fact it is potentially not.


2020-06-06 06:38:43

Willy Vanhaelen

THIS IS A VERY DANGEROUS MACRO. I tested it in a workbook with many names and it deleted most of them because they were only used in vba code. It also deleted one used in a conditional format formula.


2020-06-05 12:06:56

Marco

This macro doesn't seem to cope with names used in different sheets. It removed all names from my workbook, and a lot of things stopped working.


2019-05-17 09:56:17

Andrew

However, this macro would incorrectly delete named ranges which are only used on data validation formulae?

Please kindly clarify.

Andrew


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.