Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Non-adjusting References in Formulas.

Non-adjusting References in Formulas

Written by Allen Wyatt (last updated February 8, 2020)
This tip applies to Excel 97, 2000, 2002, and 2003


1

Everybody knows you can enter a formula in Excel. (What would a spreadsheet be without formulas, after all?) If you use address references in a formula, those references are automatically updated if you insert or delete cells, rows, or columns and those changes affect the address reference in some way. Consider, for example, the following simple formula:

=IF(A7=B7,"YES","NO")

If you insert a cell above B7, then the formula is automatically adjusted by Excel so that it appears like this:

=IF(A7=B8,"YES","NO")

What if you don?t want Excel to adjust the formula, however? You might try adding some dollar signs to the address, but this only affects addresses in formulas that are later copied; it doesn?t affect the formula itself if you insert or delete cells that affect the formula.

The best way to make the formula references ?non-adjusting? is to modify the formula itself to use different worksheet functions. For instance, you could use this formula in cell C7:

=IF(INDIRECT("A"&ROW(C7))=INDIRECT("B"&ROW(C7)),"YES","NO")

What this formula does is to construct an address based on whatever cell the formula appears in. The ROW function returns the row number of the cell (C7 in this case, so the value 7 is returned) and then the INDIRECT function is used to reference the constructed address, such as A7 and B7. If you insert (or delete) cells above A7 or B7, the reference in cell C7 is not disturbed, as it just blithely constructs a brand new address.

Another approach is to use the OFFSET function to construct a similar type of reference:

=IF(OFFSET($A$1,ROW()-1,0)=OFFSET($B$1,ROW()-1,0),"YES","NO")

This formula simply looks at where it is (in column C) and compares the values in the cells that are to its left. This formula is similarly undisturbed if you happen to insert or delete cells in either column A or B.

A final approach (and perhaps the slickest one) is to use named formulas. This is a feature of Excel?s naming capabilities that is rarely used by most people. Follow these steps:

  1. Select cell C2.
  2. Choose Name from the Insert menu, then choose Define from the submenu. Excel displays the Define Name dialog box. (See Figure 1.)
  3. Figure 1. The Define Name dialog box.

  4. In the Names in Workbook box, enter the name CompareMe. (You can use a different name, if you desire.)
  5. Erase whatever is in the Refers To box, replacing it with the following formula:
  6.      =IF(A2=B2,"YES","NO")
    
  7. Click OK.

At this point you?ve created your named formula. You can now use it in any cell in column C in this manner:

=CompareMe

It compares whatever is in the two cells to its left, just as your original formula was designed to do. Better still, the formula is not automatically adjusted as you insert or delete cells.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2876) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Non-adjusting References in Formulas.

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

Automatic Font Color Won't Print Properly

Imagine that you go to print your document, and all the text you can see on the screen just isn't there on the ...

Discover More

Controlling Date Formats in a Mail Merge

One of the data sources that Word allows you to use for your mail merges is an Excel worksheet. You may get unexpected ...

Discover More

Limiting Document Page Count

Do you need to have your document fit within a certain number of pages? This can be close to impossible to do within ...

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 (menu)

Creating an Amortization Schedule

An amortization schedule is a report that shows how the outstanding balance on a loan changes with payments made over ...

Discover More

Checking for Either of Two Text Values

Using a formula to find information in a text value is easy. Using a formula to find either of two text values within a ...

Discover More

Counting Non-Blank Cells

Need to count the number of cells in a range that are not blank? You can use the COUNTA function of a more complex ...

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 five more than 3?

2020-10-31 15:45:54

CARL CHRISTOPHER

I really like your defined named Solution but I don't think it works in my situation wondering if you could possibly give me a tip ???

I have a fairly large balance type sheet where I am taking some monthly totals in columns M,N,O,P, and Q. Let's focus on Column Q. There is a column L where I have the formula =J-Q. So at the end of the month I insert 5 new blank columns and move colum Q over to column V. So Column L now has the formula =J-V. I need column L to have the formula =J-V-Q. I hope that explains it.


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon 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.