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

Aligning Text in WordArt

WordArt provides several ways you can align whatever text you've entered. In this tip you discover the different alignment ...

Discover More

Counting Jobs Completed On a Date

When you store the date and time in a single cell, it can be a bit confusing to count how many cells contain a particular ...

Discover More

Excel 2013 Filters and Filtering (Table of Contents)

Excel provides two ways to filter your data so that only what you want to see is displayed. Discover how filtering works and ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

More ExcelTips (ribbon)

Determining a Name for a Week Number

You could use Excel to collect data that is useful in your business. For instance, you might use it to collect information ...

Discover More

Replacing Dashes with Periods

Replacing one character in a text value with another character is easy. All you need to do is use the SUBSTITUTE function, as ...

Discover More

Counting Odds and Evens

If you have a series of values in a range of cells, you may wonder how many of those values are even and how many are odd. ...

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 8Mpixels. 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 6 - 3?

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.