Sub topic 3
Anchoring references and bounding ranges
This chapter assumes you can enter formulas, know that $ locks part of a reference, and have seen a simple budget or income statement layout. The goal is to decide, for each reference in a SUMIFS or lookup formula, what should move when you copy the formula and what should stay fixed. You will also decide how far a range should extend.
Why references decide whether a model is trustworthy
A formula in a financial model is written once and then copied across months and down accounts. When you copy a formula, Excel adjusts each reference according to how it was written. If the adjustment is wrong, the formula still returns a number. Nothing flags the error, and the model reports a wrong total with full confidence.
Two decisions are involved in every lookup or SUMIFS formula:
- Anchoring: which parts of each reference move when the formula is copied.
- Bounding: how many rows the data ranges cover, and whether new data falls inside them.
The three reference styles
A cell reference has a column part and a row part. A $ in front of a part locks it.
| Written as | Column when copied sideways | Row when copied down | Name |
|---|---|---|---|
| `B5` | moves | moves | relative |
| `$B$5` | stays | stays | absolute |
| `$B5` | stays | moves | mixed, column locked |
| `B$5` | moves | stays | mixed, row locked |
Press F4 while the cursor is in a reference to cycle through these four forms.
Reading a formula for what it needs
Take the monthly SUMIFS from the topic plan:
=SUMIFS(Data!$F$2:$F$5000, Data!$B$2:$B$5000, $A5, Data!$D$2:$D$5000, ">="&C$3, Data!$D$2:$D$5000, "<="&EOMONTH(C$3,0))Suppose this formula sits in C5, with account names down column A and month start dates across row 3. Each reference has a job:
Data!$F$2:$F$5000,Data!$B$2:$B$5000andData!$D$2:$D$5000are the ledger columns. They must never move, so both the column and the rows are locked.$A5is the account name. When the formula is copied right, it must keep pointing at column A. When copied down, it must move to the next account. So the column is locked and the row is free.C$3is the month start date. When copied right, it must move to D3, E3 and so on. When copied down, it must stay on row 3. So the row is locked and the column is free.
This pattern is the standard for any grid with row labels on the left and column headers on top. Lock the column of the row label, and lock the row of the column header. The result is that one formula, written once in C5, can be copied across the whole grid.
A common error: forgetting to lock the ledger
Suppose the ledger range was typed as Data!F2:F5000 with no dollar signs. In C5 it works. Copy the formula down one row to C6 and the range becomes Data!F3:F5001. The first ledger row is silently dropped from the total. Copy it down ten rows and ten ledger rows are missing.
The worst feature of this error is that the sum range and the criteria ranges may shift by the same amount. Then they stay aligned with each other, and nothing looks broken. There are two defenses:
- Lock every data range as a habit, then unlock only what you mean to move.
- Use the reconciliation check shown later in this chapter, which compares the grid total to the ledger total.
Aligned ranges in SUMIFS
SUMIFS requires the sum range and every criteria range to have the same shape. If the sum range is Data!$F$2:$F$5000 and a criteria range is Data!$B$2:$B$4999, SUMIFS returns a #VALUE! error. That error is useful, because it flags the mistake. The dangerous case is when all ranges are the same size but start on the wrong row. If the sum range is $F$2:$F$5000 and the criteria range is $B$3:$B$5001, the ranges have the same size but each amount is paired with the account from the next row. No error appears, and the totals are wrong.
Rule: start and end every range in the same rows. Check this by looking at the row numbers in each range, not only the lengths.
Bounding ranges
The bound of a range is where it ends. There are three common choices, and each has a failure mode.
Fixed bound
Data!$F$2:$F$5000 covers 4,999 rows. It is simple, works in every Excel version, and is easy to audit. Its risk is that the ledger grows past row 5000. The extra rows are ignored without any message.
Whole column
Data!$F:$F always covers the whole column, so growth is never a problem. SUMIFS handles whole columns efficiently, so speed is rarely a concern. Two problems remain. The header text in row 1 is part of the range, which is harmless in SUMIFS because text is ignored in a sum range. But a total or a note placed lower in the same column is counted by accident. Also, in array-style lookups, whole columns can slow down calculation.
Excel table references
If the ledger is an Excel table named Ledger, you can write Ledger[Amount] instead of a cell range. The reference grows and shrinks with the table, so new rows are included automatically.
=SUMIFS(Ledger[Amount], Ledger[Account], $A5, Ledger[Date], ">="&C$3, Ledger[Date], "<="&EOMONTH(C$3,0))Table references are the least error-prone choice for growing data. The trade-off is that formulas are harder to read for people who are used to cell addresses. Also, copying the formula to another workbook can break the links.
Choosing a bound
| Situation | Suggested bound |
|---|---|
| Ledger is pasted in each period and has a known maximum | Fixed bound with spare rows, plus a check |
| Data grows daily and the sheet holds nothing else | Excel table, or whole column |
| Data sheet has totals or notes below the data | Fixed bound or table, never whole column |
| File is shared with users on old Excel versions | Fixed bound, since table behavior varies in older tools |
Lookup ranges need the same care
Lookup formulas follow the same rules. Take this formula from the plan:
=INDEX(Rates!$C$3:$H$12, MATCH($A5, Rates!$B$3:$B$12, 0), MATCH(C$4, Rates!$C$2:$H$2, 0))- The table body
Rates!$C$3:$H$12is locked fully. - The row labels
Rates!$B$3:$B$12have the same rows as the table body, 3 to 12. - The headers
Rates!$C$2:$H$2have the same columns as the table body, C to H.
Position is what links these three ranges. MATCH returns a position, such as 4, and INDEX uses that number inside a different range. If the label range started at row 2 but the body started at row 3, every result would be off by one row, and the formula would return a neighbor's rate with no error. Both ranges must start on the same row.
Inserting rows and columns
Excel adjusts references when rows are inserted inside a range. It does not adjust a range when rows are added just below the last row. Suppose the assumptions list is Assumptions!$B$3:$B$12 and you type a new assumption into row 13. The lookup does not see it. Two safe habits:
- Insert new rows between existing rows, not after the last one.
- Include one blank spare row at the end of the range, so that inserting above the blank row expands the range.
Worked example
You have a ledger on a sheet called Data with rows 2 to 5000, and a summary sheet with account names in A5:A20 and month start dates in C3:N3. Build the grid.
- In C5, enter the monthly SUMIFS formula shown earlier.
- Copy C5 to the whole block C5:N20.
- Check one cell in the bottom right. Click N20 and confirm the account reference reads
$A20, the date reference readsN$3, and the ledger ranges still read rows 2 to 5000. - In a total row, add the check
=ROUND(SUM(C21:N21) - SUM(Data!$F$2:$F$5000), 2), where row 21 holds the monthly totals. A result of zero means every ledger row landed in some cell of the grid.
Step 3 takes ten seconds and catches the most common anchoring mistakes. Ctrl+` (grave accent) shows all formulas on the sheet at once, which makes inconsistent references easy to see.
Summary of rules
- Lock data ranges fully with
$on both column and row. - Lock the column of row labels and the row of column headers.
- Start and end all ranges used together in the same rows or columns.
- Choose a bound deliberately, and add a check that exposes data outside it.
- Insert rows inside ranges, not below them.
Exercise
A formula in C5 is =SUMIFS(Data!F2:F5000, Data!B2:B5000, A5, Data!D2:D5000, ">="&C3). The formula is copied to C6. Rewrite it so that it can be copied across and down a grid with accounts in column A and month dates in row 3, and explain what would have gone wrong in C6.
Show answer
Rewrite: =SUMIFS(Data!$F$2:$F$5000, Data!$B$2:$B$5000, $A5, Data!$D$2:$D$5000, ">="&C$3). In C6 the original becomes Data!F3:F5001 for all three ranges, so ledger row 2 is dropped from the total, and the date reference moves to C4, which is not the header row, so the date criterion reads the wrong cell. Locking the ledger ranges fixes the first problem. Locking the row in C$3 fixes the second. Locking the column in $A5 keeps the account label in column A when copied right.
Exercise
A lookup is =INDEX(Rates!$C$3:$H$12, MATCH($A5, Rates!$B$2:$B$11, 0), 2). Every result is the rate for the account listed one row above the intended one. What is the cause and the fix?
Show answer
The row-label range starts on row 2 while the table body starts on row 3, so MATCH returns a position that is one row too early for INDEX. Change the label range to Rates!$B$3:$B$12 so it covers the same rows as the body.