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)

9

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

Running a Macro in a Number of Workbooks

Got a macro that you need to run on each of a number of workbooks? Excel provides a number of ways to go about this task, ...

Discover More

Extra Spaces after Inserting a Building Block

Building blocks are a great tool for inserting standard information in your documents. It is also possible, however, to ...

Discover More

Averaging without Hidden Cells

Grabbing an average of a range of cells is easy using Excel functions. If you want that average to ignore hidden cells ...

Discover More

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!

More ExcelTips (ribbon)

Finding the Nth Occurrence of a Character

The FIND and SEARCH functions are great for finding the initial occurrence of a character in a text string, but what if ...

Discover More

Calculating the Median Age of a Group of People

Suppose you have a worksheet that contains a list of ages and then a count of people who correspond with those ages. You ...

Discover More

Deriving High and Low Non-Zero Values

When analyzing your numeric data, you may need to figure out the largest and smallest numbers in a set of values. If you ...

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 9 - 6?

2019-08-22 12:03:17

Peter Atherton

To those concerned
The following macro is more flexible and the one I use.

Sub ConverFormulaReferences()
'Updateby20140603
'Extended Office
Dim Rng As Range
Dim WorkRng As Range
Dim xName As Name
Dim xIndex As Integer
Dim xTitleId As String
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)
xIndex = Application.InputBox("Change formulas to?" & Chr(13) & Chr(13) _
& "Absolute = 1" & vbLf _
& "Row absolute = 2" & vbLf _
& "Column absolute = 3" & vbLf _
& "Relative = 4", xTitleId, 1, Type:=1)
For Each Rng In WorkRng
Rng.Formula = Application.ConvertFormula(Rng.Formula, XlReferenceStyle.xlA1, XlReferenceStyle.xlA1, xIndex)
Next
End Sub

A big thanks to Extended Office


2019-08-20 13:33:05

Angela

You're my go to whenever Excel stumps me. I am most grateful, by far, for this tip! I know little about Macros, but followed all of the related instructions and updated more than 400 formulas in under a minute. I cannot thank you enough!


2019-08-06 06:52:46

Daniel

you just saved me about an hour of work, thanks so much!


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.