Written by Allen Wyatt (last updated July 17, 2024)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365
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.
Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!
Want a quick way to enter a series of single digits into consecutive cells? The best approach is with a macro, and this ...
Discover MoreExcel provides keyboard shortcuts for a variety of purposes. This tip examines two such shortcuts, designed to allow ...
Discover MoreGot some numbers and letters mixed up in the same cell? You may need to get rid of those letters so you are left with ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2024-07-18 04:11:01
Mike J
Re my comment below, I should have mentioned that it only works when all the references in the worksheet are unambiguous. For instance $Q4 or references to say Q41, or any variation of these will end up incorrect. So using a macro is still the best solution.
2024-07-17 12:41:42
Mike J
What does seem to work:
Drag Q4 to an empty cell (Q2 say)
Drag Q3 to Q4
Drag Q2 to Q3
The name references are now pointing to Q3
ReplaceAll $Q$3 with $Q$4
Now the formulae are pointing to Q4 and the name references to Q3, without messing up the layout, or losing Undo.
2024-07-17 05:43:26
jamies
And if redoing names, why not consider actually applying a name to just the specific cell, then replacing the cell reference with the newly set name for the cell.
and, maybe even having that newly specified name being an offset from a base cell of a set of controlling, or range specifying names of locations.
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.
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.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments