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.

by Allen Wyatt
(last updated July 21, 2017)

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

Assigning a Macro to a Button in Your Text

One way you can access macros is through the use of a button, added directly into the text of your document. This is done ...

Discover More

Creating a Footer

Adding a predefined footer to your worksheets is easy, and it helps convey valuable information when you make a printout. ...

Discover More

Returning the Smallest Non-Zero Value

In a series of values you may need to know the smallest value that isn't a zero. There is no built-in function to do ...

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!

Counting Cells According to Case

Text placed in cells can either be lowercase, uppercase, or a mixture of the two. If you want to count the cells based ...

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

Discover More

Listing Combinations

You can easily use the COMBIN worksheet function to determine the number of combinations that can be made from a given ...

Discover More
##### Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

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

2019-01-31 19:08:29

Lisa

I finally understand INDIRECT now, thanks to you! Much appreciated.

2019-01-26 11:57:44

Gera

For some weird reason I thought that relative references didn't work inside if statements, because they didn't seem to be working. They kept returning the same value (invoice number) even though some should have been blank. Upon closer inspection, they were different references (rows). But why the same number? I hit save on an instinct and the forumas updated. So why did that setting change? I remember it changed last week. Nobody is on my computer but me and the IT guy but we use an application whose own plug in often gets disabled and it's not out of the possibility that this setting changes maybe. Maybe it's an environmental variable, I don't know.

2017-11-23 09:38:34

George

"Named Formula"! Something I've been having to work around for decades and now.. finally! Thank you!!!

2017-04-29 09:07:51

Rajan

Re-writing the question:

I have a cell reference in one of my cells down a column, for example:

(see Figure 1 below)

When I insert a row in Excel and copy formulas from above row, the cell reference in 'Opening Stock' does not update automatically in first following row after the new blank row (should be equal to previous row balance, which is 60 now). But it updates correctly in all other rows below. Is there a way to force Excel to update cell reference to the cell in blank row above?

Have searched the web, but did not get any satisfactory answer. I do not want to convert the data to a table, since it messes up the filters and formatting. Macros don't solve the problem either - they don't copy to the row following the blank one.

It may be mentioned that I found the original Excel problem on other computers at my home and work place and in online spreadsheets too. So it is not related to my computer or my version of Excel.

Figure 1.

2016-10-31 17:59:31

Steven

DUDE! I want to kiss you. I've been looking all over for a way to use an IF formula without it getting messed up when I insert.

2016-10-06 10:05:18

stoica aurora

I am using the following formula and when i insert a row in the source worksheet i would like F56 to change to F57 but it does not.

INDIRECT("'"&A2&"'"&"!" &"F56")

2016-07-15 12:36:16

Ernie

I am using the following formula and when i insert a row in the source worksheet i would like F56 to change to F57 but it does not.

INDIRECT("'"&A2&"'"&"!" &"F56")

2016-03-31 10:45:51

yonas

hello, help me how can i solve the ff
A B C D
i need to add the value of A to C and the value of C should not be changed if i delete A is should be constant and must add to C if i inter a number to A.
in short the value of C should be increase as i inter data to A.

2016-03-23 13:26:32

James

This was extremely helpful. I am managing a database that is inter-related another's database. I have cross checked their 500+ records but I have no way of knowing when a record is added to the other db. So I have my list, my snapshot of theirs at a certain point in time and, now and again, I need to compare a new snapshot to the old and see what has been added. This allows me to scroll down the list and add a cell now and again to bring things back into alignment, by rows, which highlights what is new in the other database and needs to be integrated into mine. So far, this is the only solution that has worked.

2016-03-01 17:42:08

Cliff Miller

Wow, the named formula was just what I needed. I'm using a macro to insert new data and push over old data. It was a pain to see formulas referencing specific cells (for a graph of last 7 days) move along with the pushed data, but that did the trick and was so easy! Thanks a ton!

2015-10-08 17:17:21

Brent

I'd like to second what LesW asked. I've been wondering how to do it for years.

2015-06-15 15:53:46

Kelv

The define name saved me a lot of time! Thanks a lot for sharing!

2015-05-31 12:29:04

LesW

What if you were inserting a column that had a formula and you wanted the formula to update to include the new column. For example, in column D you had =sum(A1:C1) and you inserted a column to the left of D. The formula in E should now read =sum(A1:D1) but it doesn't. It stays at A:C. But if you insert a column to the left of B or C the formula in E is updated to A:D. Can you use OFFSET or INDIRECT to help update the formula in E?

2015-01-29 16:15:26

Jeff

This saved us a lot of time! Thank you.

2015-01-22 10:22:48

DaveBoltie

Well now... The best way to make the formula references "non-adjusting" is to just press F2, then copy the formula as text, and paste it into another cell. The references are not adjusted. Seems much simpler than INDIRECT, which you may not have in your formula to start with

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