Changing References in a Lot of Defined Names

Written by Allen Wyatt (last updated February 26, 2024)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


4

Bud has 50 or 60 defined names in a workbook. In a lot of these, he needs to change any occurrence of $Q$4 to $Q$3. Bud can pull these up in the Name Manager and edit them individually, but he's wondering if there is a way to do it in a less manual manner.

There are two ways you can approach this issue. The first is to try to "cheat" and have Excel do the changing. Select the current cell Q3 and then delete that cell, moving the cells upwards. That will move the current Q4 to Q3, and Excel should update all references (including any defined names) to now reference Q3.

Of course, this won't work if making the deletion messes up the layout of your worksheet. In that case, you would be better served to use the second approach, relying on a macro. The macro can easily step through each of the defined names and make the replacement. Here's a very simple example:

Sub ReplaceFormulasInNames()
    Dim n As Integer

    For n = 1 To Names.Count
        Names(n).RefersTo = Replace(Names(n).RefersTo, "$Q$4", "$Q$3")
    Next
End Sub

The macro examines the RefersTo property for each name and, if it contains the text $Q$4 it is changed to $Q$3.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (13654) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365.

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

Standardizing Note Reference Placement

Want to modify where an endnote or footnote reference appears in relation to the punctuation in a sentence? Here's a way ...

Discover More

Inserting a File

Need to combine several files into a single document? You can do it by inserting one file into another, as outlined in ...

Discover More

Checking Lock Status of Cells

When you first create a worksheet, all the cells in that worksheet are formatted as locked. As you unlock various cells ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (ribbon)

Identifying Duplicates

Do you need to flag duplicate values in your data? This tip shows three different ways you can do the flagging you need.

Discover More

When Clicking a Cell, Excel Jumps to a Different Cell

When you click on a cell, you expect the cell to be selected. What happens, though, if you are instead taken to an ...

Discover More

Ensuring Standard Units During Data Entry

Need to make sure that information entered in a worksheet is always in a given unit of measurement? It's not as easy of a ...

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 5 - 3?

2019-07-29 13:47:04

Willy Vanhaelen

@Craig Abt
You didn't pay attention to my last comment. Of course what you suggest works fine but that's not the issue here.


2019-07-29 11:25:04

Craig Abt

Would another option be to use the find and replace function by selecting the range of cells containing the cell reference to be changed? Access the find and replace function (CNTL H), typing in "$Q$4" in the find field, and "$Q$3" in the replace field.
Craig


2019-07-28 06:15:45

Willy Vanhaelen

@Rick Schubert
You should read this tip more carefully. Bud doesn't want to change $Q$4 to $Q$3 in formulas but in the address defined names refer to. That is a big difference.

And even if you want to change anything in formulas you can do it without showing the underlying formulas.


2019-07-27 11:54:06

Rick Schubert

An easier way is to first type CNTL-`, which will display the formulas in the cells. Then you can use the standard Replace editing feature of Excel: enter $Q$4 in the "Find what:" box and "$Q$3" in the "Replace with:" box. After the replacement is done, type CNTL-` again to change the display back to the normal display that will display cell values rather than formulas.


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu 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.