Changing References in a Lot of Defined Names

by Allen Wyatt
(last updated July 27, 2019)

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

Understanding the ADVANCE Field

You can use the Advance field to change where text is positioned in your document. This tip shows how to use it and the ...

Discover More

Italic Typing Doesn't Stay Italic

If you turn explicit formatting on and off as you type, you may notice some quirky behavior in Word. This tip examines ...

Discover More

Making Sure Styles Do Not Update Automatically

One of the features of Word that can cause some problems is one that allows styles to be automatically updated based upon ...

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)

Removing Cells from a Selected Range

Select a large range of cells and you may later want to remove a few cells from that selection. This is not as easy as ...

Discover More

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

Defining Shortcut Keys for Symbols

Do you need to use symbols frequently in your Excel data? The common way to insert them is by using the Symbol dialog ...

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}] 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 1 + 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.