Skip to main content

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:


arrow blue right bubble 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



arrow blue right bubble 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

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more

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

Description


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!
Comments (1)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Muchas gracias por el post! Me ha funcionado la macro perfectamente, una ayuda buenísima
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations