How to replace range names with cell references in Excel?
Some people prefer to use lots of range names in their formulas because they feel it is clearer and easier to read and understand. But if you want to see the actual cell references, how should you do? Here this tutorial will introduce two quick tricks to solve this problem.
Replace range names with VBA code;
Quickly and easily replace range names with Kutools for Excel.
For example, in this worksheet, I will name range A2:A6 as saleprice, and name B2 as discount, and then using both the range name in a formula to calculate the new price. See screenshot:
After following the quick tricks, the range name will be replaced with cell reference as shown as below:
Replace range names with VBA code
Using VBA to replace formula’s range names with cell references, you can get it done step by step as follows:
1. Select the range containing the formulas you want to replace their names with cell references.
2. Click Developer > Visual Basic or Alt + F11 to open a new Microsoft Visual Basic for applications window will display, click Insert>Module, and then input the following codes in the module:
VBA code: Replace range names with Absolute reference
Sub AbsoleteNamesWithRelativeRefs()
'Updateby20140603
Dim Rng As Range
Dim WorkRng As Range
Dim xName As Name
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
Set WorkRng = WorkRng.SpecialCells(xlCellTypeFormulas)
For Each Rng In WorkRng
For Each xName In ThisWorkbook.Names
If InStr(Rng.Formula, xName.Name) > 0 Then
Rng.Formula = VBA.Replace(Rng.Formula, xName.Name, VBA.Replace(VBA.Replace(xName.RefersTo, "=", ""), "$", ""))
End If
Next
Next
End Sub
VBA code: Replace range names with relative reference
Sub ReplaceNamesWithRelativeRefs()
'Updateby20140603
Dim Rng As Range
Dim WorkRng As Range
Dim xName As Name
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
Set WorkRng = WorkRng.SpecialCells(xlCellTypeFormulas)
For Each Rng In WorkRng
For Each xName In ThisWorkbook.Names
If InStr(Rng.Formula, xName.Name) > 0 Then
Rng.Formula = VBA.Replace(Rng.Formula, xName.Name, VBA.Replace(xName.RefersTo, "=", ""))
End If
Next
Next
End Sub
3. Then click button to run the code, a dialog displays for selecting a range to replace. See screenshot:
4. Then click OK. and all of the selected formula range names have been replaced. See screenshot:
Replace range names with relative cell references |
Replace range names with absolute cell references |
Quickly and easily replace range names with Kutools for Excel
If you have Kutools for Excel, its Replace Range Names utility will help you replace range names with cell references quickly and easily.
Kutools for Excel: with more than 300 handy Excel add-ins, free to try with no limitation in 30 days. Get it Now
Step 1. Please apply this utility by clicking Kutools > More Tools > Replace Range Names. See screenshot:
Step 2. A pop-up dialog named Replace Range Names is displayed, and click Range section and then select the range you want to replace with cell references from the Base Range. See screenshot:
Step 3. Click Replace, another Replace Range Names pop-up dialog will be displayed to tell you the number of modified formulas and unchanged formulas, click Ok, and then the range names in the selected rang have been replaced with cell references. See screenshot:
For more detailed information about Replace Range Names, please visit Replace Range Names feature description.
Relative Article:
Change cell reference in formulas to range names in Excel
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!