Loading
Excel.Tips.Net ExcelTips (Menu Interface)

Converting from Relative to Absolute

Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Converting from Relative to Absolute.

Excel allows you to easily edit formulas. In doing so, you can quickly change a cell reference or a range reference from relative to absolute. What if you have a large number of cells in which you need to change from relative to absolute referencing? In this instance, the nature of the problem is well-suited to being solved through a macro.

By using the ConvertFormula method available in VBA, you can easily convert a formula from relative to absolute addressing. The following short macro uses this method to change the addressing method used in a range of cells:

Sub Relative2Absolute()
For Each c In Selection
    If c.HasFormula = True Then
        c.Formula = Application.ConvertFormula(c.Formula, _
          xlA1, xlA1, xlAbsolute)
    End If
Next c
End Sub

The key to how this macro works is, of course, in the ConvertFormula method. The last parameter used by the method is—in this case—xlAbsolute. If you want to adapt the macro so that it changes to other types of addressing, you can change xlAbsolute to xlRelative, xlAbsRowRelColumn, or xlRelRowAbsColumn. (I'm sure you can figure out the purpose of each constant by its name.)

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (1927) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Converting from Relative to Absolute.

Related Tips:

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

 

Leave your own comment:

*Name:
Email:
  Notify me about new comments ONLY FOR THIS TIP
Notify me about new comments ANYWHERE ON THIS SITE
Hide my email address
*Text:
*What is 5+3 (To prevent automated submissions and spam.)
 
 
           Commenting Terms

Comments for this tip:

Howard    09 May 2016, 13:55
This page is an exact duplicate of http://excelribbon.tips.net/T010738_Converting_from_Relative_to_Absolute.html

I think Allen wanted one of them to show you how to go from Absolute to Relative.

The change is very small:

Sub Absolute2Relative()
For Each c In Selection
    If c.HasFormula = True Then
        c.Formula = Application.ConvertFormula(c.Formula, _
          xlA1, xlA1, xlRelative)
    End If
Next c
End Sub
Robert    16 Jun 2015, 09:51
Not working for me in Excel 2010.

My cells to be converted all contain simple references to single cells on another tab in the same workbook. No computations. Example ='TabName'!A1

Result when using your code is always the same for me, but using Microsoft's similar example (lots more VB to let the user enter A or R) it works sometimes. Most cells fail with MS's version also. Example of result ='[FileName]TabName'!$A$1

When the MS version succeeds, however, the result is ='TabName'!$A$1

Ok both look plausible, EXCEPT when the failure occurs, the reference does NOT resolve to the value in the referenced cell. Instead, Excel displays the result formula as though it were text. In the failure case, I see the exact formula text as above. In the few cases that succeed, I see the value of the referenced cell.

So I manually removed [FileName] on a few broken result cells. Still displays the formula as text, not the value.
Ray    24 Mar 2014, 11:17
What if I need the first part of teh equation to be absoulte and the second xlRelRowAbsColumn (i.e, $R$32*$T32). I have found several discussion about one way or the otehr but not this combination
 
 

Our Company

Sharon Parq Associates, Inc.

About Tips.Net

Contact Us

 

Advertise with Us

Our Privacy Policy

Our Sites

Tips.Net

Beauty and Style

Cars

Cleaning

Cooking

DriveTips (Google Drive)

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2016)

Gardening

Health

Home Improvement

Money and Finances

Organizing

Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2016)

Our Products

Helpful E-books

Newsletter Archives

 

Excel Products

Word Products

Our Authors

Author Index

Write for Tips.Net

Copyright © 2016 Sharon Parq Associates, Inc.