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.
by Allen Wyatt
(last updated December 9, 2014)
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:
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.
Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!
When entering data in a worksheet, you may only want to add information to the cells in a particular range. You can easily do ...Discover More
Do you need to concatenate the contents of a range of cells in the same column? Here's a formula and a handy macro to make ...Discover More
Type some information into a worksheet, and you may notice that Excel automatically capitalizes some of your information. ...Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
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.