Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. 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

Written by Allen Wyatt (last updated April 10, 2021)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


1

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()
    Dim c As Range

    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 regarding 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, 2013, 2016, 2019, and Excel in Microsoft 365. 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

Checking for an Entry in a Cell

You may be looking for a way to have a formula determine if a particular cell has anything in it. Here's how you can find ...

Discover More

Duplex by Default

Many printers these days have the capability to print on both sides of a piece of paper. You may want Word to use this ...

Discover More

Word 2016 Indexes and Special Tables (Table of Contents)

One of the finishing touches used in some types of documents are an index or a special table, such as a table of ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (ribbon)

Stopping a Formula from Updating References

Insert or delete a column, and Excel automatically updates references within formulas that are affected by the change. If ...

Discover More

Returning a Weight and a Date

If you have two columns containing dates and weights from those dates, you may want to pick a date associated with a ...

Discover More

Locating a Single-Occurrence Value in a Column

Given a range of cells containing values, you may have a need to find the first value in the range that is unique. This ...

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}] (all 7 characters, in the sequence shown) 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 nine minus 5?

2021-10-07 15:54:14

SMW

One problem with this - the insertion of @ sign:
=INDEX(C86:CI109,ROW(A1),
LARGE(IF(LEN(C86:CI86)>0,
COLUMN(C86:CI186),""),
COLUMNS(A1:A1))-COLUMNS(A1:B1))

becomes:

=@INDEX($C$86:$CI$109,ROW($A$1),
LARGE(IF(LEN(@$C$86:$CI$86)>0,@
COLUMN($C$86:$CI$186),""),
COLUMNS($A$1:$A$1))-COLUMNS($A$1:$B$1))

and vice versa


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.