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

Converting from Relative to Absolute

by Allen Wyatt
(last updated February 14, 2015)

6

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

There is one other thing to remember in regards to the ConvertFormula method: It has a length limit of 255 characters. That means that if your formula is very long, it is possible that the method won't work as you'd like. The best way to figure out if it will work for your needs is to test it out.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10738) applies to Microsoft Excel 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Excel here: Converting from Relative to Absolute.

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

Paragraph Numbers in a TOC

Word is great at creating a simple, straightforward table of contents. If you want a more non-traditional TOC, however, ...

Discover More

Using Tags with Document Files

Tags are a way for you to store keywords or metadata with your document files. They can be helpful when you are trying to ...

Discover More

AutoFill Won't Work as Expected

AutoFill is a great tool for filling cells with data. What do you do when it doesn't work like you expect, however? ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (ribbon)

Using Named Formulas Across Workbooks

You can use the naming capabilities of Excel to name both ranges and formulas. Accessing that named information in a ...

Discover More

Concatenating Values from a Variable Number of Cells

Excel makes it easy to concatenate (or combine) different values into a single cell. If you need to combine a different ...

Discover More

Determining "Highest Since" or "Lowest Since"

When compiling statistics on a collection of data points, you may want to know whether a particular value is the "highest ...

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}] 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 8 - 1?

2017-05-05 20:04:51

Prabir Mittra

Thank you.

I am a intermediate excel user. I found this tip fantastic as i avoided converting from Relative to Absolute by manually using F4 in each cell.

Prabir Mittra
Malaysia


2016-12-13 11:41:38

Hannes Koppatz

Dear all,
I've coded
myCell.Value = Application.ConvertFormula(myCell.Formula, xlA1, xlA1, xlAbsolute)
and it goes wrong, but
myCell.Value = Application.ConvertFormula(myCell.Formula, xlR1C1, xlA1, xlAbsolute)
works well.
Please change the second parameter of your method-call.

By the way: A general switch of R1C1 to A1-style or vice versa is not a solution for me.
I've implemented a SQL-Mechanism (by ADO) for Worksheets in combination of udf's.
Example: SELECT Name, '=udfTrim(RC[-1])' as Formula1 FROM ...
and these relative formulas has to be converted "on the fly" to absolutes.
And it works fine !

best regards !


2016-11-19 05:46:08

Steve

Efren,
In B4 you need =sum(A1:A3)-B5


2016-11-18 06:53:20

Efren

Sir Good Day, How can I automatically Sum Up the total values of a Column to the next column by not making prompt the summation formula, with that formula I may just copy to the rest of the rows to do the same task. To be clear let say I encoded Column A from Cell 2 to 3 wit Amounts of 5,10 and 6 Respectively, I want it to be copied the sum of 21 automatically to Column B at Cell4, and once put a value in column B at Cell5 the Total of 21 will be lessened by the value I put in Cell5. Thanks and Good Day


2016-11-18 02:54:44

John Wilkinson

Hello,

Your macro did not work.

However when I added:

Dim c As Variant

to it, problem solved.

Audrey mentions ASAP Utilities - seems as though that is an add on that one must purchase!


2015-07-23 10:39:06

ExcelGeek Audrey

There is a much simpler way to change a range of cells without running a macro. Select the range you'd like to change, Go to ASAP Utilities and select "Change formula reference style". Here you can select which parts or all of the formulas to change to absolute referencing. :)


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.