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

Counting Characters in Text Boxes

When you do a word count, the value that is returned does not include any text contained in text boxes. This may not be a ...

Discover More

Deleting All Names but a Few

Want to get rid of most of the names defined in your workbook? You can either delete them one by one or use the handy ...

Discover More

Making a List of Words Italic

You can use Find and Replace to change the attributes of text in your document. When you want to make changes to lots and ...

Discover More

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!

More ExcelTips (ribbon)

Changing Months in a Workbook

When you copy a worksheet and then need to make changes to information in that worksheet (such as changing month names), ...

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

Moving Cells Using the Mouse

Want to easily move information from one cell to another? A quick way to do it is to simply drag and drop using the mouse.

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 one less than 9?

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.