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.

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

Setting Default Print Margins

Don't like the print margins that Excel uses by default? You can change the default by changing the workbook on which Excel ...

Discover More

Watermarks in Columns

If you are creating small flyers (two per page), you may want to include a watermark graphic in the background of each of the ...

Discover More

Adjusting Row Height for a Number of Worksheets

Adjusting the height of a row or range of rows is relatively easy in Excel. How do you adjust the height of those same rows ...

Discover More

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

More ExcelTips (ribbon)

Getting a Conditional Count of Cells Containing Values

Excel provides several worksheet functions that can be used to count cells containing values—particularly numeric ...

Discover More

Condensing Sequential Values to a Single Row

If you have a bunch of ZIP Codes or part numbers in a list, you may want to "condense" the list so that sequential series of ...

Discover More

Exact Formula Copies

When you copy a formula from one cell to another, Excel normally adjusts the cell references within the formula so they are ...

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