Excel errors

Circular reference warning in Excel: how to find and fix it

Fix a circular reference in Excel: totals that include themselves, running balances, indirect loops. Find it on the status bar; iterative calculation explained.

A circular reference happens when a formula depends, directly or through other formulas, on its own result. The simplest example is a total that includes its own cell: =SUM(B2:B6) written in B6. Excel cannot calculate a value that needs itself as an input, so it shows a warning that the workbook contains circular references and may calculate incorrectly, writes the cell's address on the status bar, and usually returns 0. Unlike the error values such as #REF!, a circular reference does not show an error code in the cell, which is what makes it dangerous: the numbers look normal. This page shows the common ways a circle is created, how to find it and how to break it, and when an intentional circle with iterative calculation is acceptable. For the error values see Formula errors: what each one means and how to fix it.

What a circular reference means

Excel calculates a workbook by working out each cell after the cells it depends on. A circle has no starting point: A needs B, B needs C, C needs A. When you enter such a formula Excel shows the warning once; after you close it the status bar keeps showing Circular References followed by a cell address for as long as the circle exists. The cells involved show 0 or the last value they had, and formulas that depend on them can be silently wrong.

Cause 1: a total that includes its own cell

The classic slip: the SUM range is dragged one row too far and includes the total cell.

B6fx=SUM(B2:B6)
AB
1ExpenseAmount
2Rent120
3Travel80
4Software200
5Training50
6Total0

B6 is inside its own range. Excel warns and shows 0.

Result: 0

B6fx=SUM(B2:B5)
AB
1ExpenseAmount
2Rent120
3Travel80
4Software200
5Training50
6Total450

The range stops above the total: 120 + 80 + 200 + 50 = 450.

Result: 450

The same happens with a whole-column reference placed in that column, such as =SUM(B:B) in B6. Put whole-column totals in another column, or above the data on a different sheet.

Cause 2: a running total that points at itself

A running balance should add the amounts up to the current row. A common slip refers to the balance column instead:

C3fx=SUM($C$2:C3)
ABC
1DateAmountBalance
201-Mar500500
302-Mar-1200
403-Mar300

C3's range includes C3 itself, so the formula is circular.

Result: 0

C3fx=SUM($B$2:B3)
ABC
1DateAmountBalance
201-Mar500500
302-Mar-120380
403-Mar300

Add the Amount column instead: 500 - 120 = 380. Filled down, C4 gives 680.

Result: 380

Cause 3: an indirect circle across several cells

Circles are often spread across formulas that each look reasonable. A classic is a bonus pool of 10% of profit, where profit is calculated after the bonus:

Formula
B4  Profit:  =B2-B3-B5     (revenue - costs - bonus)
B5  Bonus:   =10%*B4       (10% of profit)
B4 needs B5 and B5 needs B4: an indirect circular reference.

Fix. Solve the relationship with a little algebra so that each cell depends only on inputs. If the bonus is 10% of the profit after bonus, then Bonus = 0.1 × (Revenue - Costs - Bonus), which rearranges to Bonus = 0.1 × (Revenue - Costs) / 1.1:

B5fx=0.1*(B2-B3)/1.1
AB
1ItemAmount
2Revenue250000
3Costs140000
4Profit100000
5Bonus10000

110,000 × 0.1 ÷ 1.1 = 10,000; Profit becomes =B2-B3-B5 = 100,000, and 10% of 100,000 is indeed 10,000.

Result: 10000

Other frequent indirect circles: interest calculated on an average balance that includes the interest itself, a VAT cell that refers to a total that includes the VAT, and lookup ranges such as =XLOOKUP(A5, A:A, D:D) written inside column D.

Cause 4: functions that look at their own cell

Some formulas reach their own cell without an obvious range: INDIRECT or OFFSET that build a reference to the formula's own position, a named range that includes the cell, or a SUMIF whose sum range covers the column the formula sits in. Fix: use Trace Precedents on the cell to see exactly which cells it reads.

How to find every circular reference

  1. Look at the status bar at the bottom of the window: it shows Circular References: B6 (the address of one cell in a circle on the active sheet; without an address, the circle is on another sheet).
  2. Choose Formulas › Error Checking (the arrow beside it) › Circular References. The submenu lists cells involved; click one to jump to it. After fixing that circle the list moves on to the next one.
  3. On the cell, use Formulas › Trace Precedents repeatedly. The arrows lead around the loop back to the starting cell.
  4. If you see the warning when you open a file, check every sheet; the circle may be on a sheet you rarely look at, or inside a named range or conditional formatting formula.
Tip. The circular reference list only shows circles that are being calculated. If calculation is set to Manual, press F9 first.

Intentional circles: iterative calculation

Some financial models use circles on purpose, for example interest on an average debt balance where the balance depends on the interest. Excel can calculate such models by repeating the calculation until the values stop changing. Turn it on with File › Options › Formulas › Enable iterative calculation (on a Mac: Excel › Preferences › Calculation › Limit iteration) and set Maximum Iterations (default 100) and Maximum Change (default 0.001).

  • The setting applies to the whole Excel session, and Excel takes it from the first workbook you open. With it switched on, Excel no longer warns about accidental circles in any open workbook.
  • Results depend on the starting values and can differ slightly from one recalculation to the next; a model that does not converge can drift to huge values (see #NUM! error in Excel: causes and how to fix it).
  • Add a "circuit breaker": a switch cell (1 or 0) and =IF($Z$1=1, formula, 0) in the circular cell, so you can break the loop if the model blows up.
  • Prefer algebra (Cause 3) or a copy-paste-values macro where possible; reviewers and auditors treat deliberate circles with suspicion.

Version notes

  • Circular reference warnings and iterative calculation exist in every version of Excel, including Excel for the web and Excel for Mac.
  • Excel for the web also warns about circular references; its iterative calculation switch sits with its other calculation settings, which differ slightly from the desktop menus.
  • Google Sheets shows a #REF! error with the message "Circular dependency detected" instead of a warning, so a file can look different there.

Check yourself

1. Where does Excel show the address of a circular reference after you dismiss the warning?

2. B6 contains =SUM(B2:B6). What is wrong?

3. What is a risk of turning on iterative calculation?

More excel errors