Changing References in a Lot of Defined Names

Written by Allen Wyatt (last updated July 27, 2019)
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

Notification when Caps Lock is Active

You're typing along, look up at your screen, and notice that everything is in ALL CAPS. Drat! You activated the Caps Lock ...

Discover More

Printing Just the Visible Data

In a large worksheet, you may want to display and print just a portion of the available data. Displaying the desired ...

Discover More

Keyboard Changes to Unwanted Foreign Language

There you are typing along, minding your own business, when wham! You end up in an entirely different language and you ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (ribbon)

Switching Editing Location

Excel allows you to edit the contents of a cell in two places--"the cell itself or in the Formula bar. If you want to ...

Discover More

Displaying an Input Format in a Cell

Want to show a user, in a cell, what you expect their input to look like? Unfortunately, it cannot be done natively in ...

Discover More

Changing Multiple Cells at Once

Excel includes several different methods of editing information in your cells. If you want to edit multiple cells all at ...

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 seven minus 1?

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.