Sub topic 6
Referring to a Whole Spill Range with #
A spill formula returns a block of cells whose size can change. This chapter covers the spill range operator, #. It gives you one reference that always matches the current block. You will see how to use it, how it behaves when the spill changes, and where it fails.
This chapter assumes you can enter formulas in Excel for Microsoft 365 or Excel 2021 or later. It also assumes you know what an anchor cell is and how a formula spills, which earlier chapters covered.
Why a fixed reference breaks
Suppose E2 holds =SORT(UNIQUE(A2:A20)). Today it returns eight names in E2:E9. A formula that totals or counts those names could point at E2:E9. That reference is fixed. If the source data changes and the spill grows to twelve names, the fixed reference still covers only eight cells. If the spill shrinks, the reference includes cells that are now empty.
The spill range operator solves this. You write the address of the anchor cell and add # after it.
=SUM(E2#)E2# means "the whole spill range whose anchor cell is E2, as it is right now." Excel recalculates the reference each time the spill changes size. The SUM stays correct without any edit.
The syntax
The # goes directly after a single cell address, with no space.
| Written | Meaning |
|---|---|
| `E2#` | The full spill range anchored at E2 |
| `E2:E9` | A fixed range of eight cells |
| `Sheet2!E2#` | The spill range anchored at E2 on Sheet2 |
| `'Q1 Data'!E2#` | The same, for a sheet name that needs quotes |
You can type the # yourself. You can also click the anchor cell while building a formula. Excel then offers the spill reference in the formula suggestions, and selecting it inserts the # for you.
Note that # also appears in error values such as #SPILL!. In E2# it is an operator that follows a cell reference. It is not part of an error.
What `#` returns
The result of E2# is an array. It has the same shape as the spill: a column, a row, or a grid. Any function that accepts a range or an array can take it as an argument. These are common uses.
=COUNTA(E2#)=ROWS(E2#)=INDEX(E2#, 1)COUNTA counts the items. ROWS returns the number of rows in the spill. INDEX picks the first item. Because the reference tracks the spill, these answers update when the data does.
You can also pass E2# into another array function, and that new formula spills too. In this example, G2 sorts the list produced in E2.
=SORT(E2#, 1, -1)If E2 grows, G2 grows with it. This is the main way to build a chain of dependent formulas, where each step uses the output of the one before.
A worked example
Set up this small table in A1:C7. Row 1 holds headings.
| Region | Product | Sales |
|---|---|---|
| East | Pens | 120 |
| West | Pens | 90 |
| East | Paper | 150 |
| North | Pens | 60 |
| West | Paper | 200 |
| East | Pens | 80 |
Enter this in E2 to list the regions without duplicates.
=SORT(UNIQUE(A2:A7))It spills East, North and West into E2:E4. Now enter this in F2, a column next to the list.
=SUMIF(A2:A7, E2#, C2:C7)Passing E2# as the criteria makes SUMIF evaluate once per region. The result spills in F2:F4 as 350, 60 and 290. The two spills line up row by row, because both come from the same count of regions.
Now add a row to the source data with a new region, South, and extend the source references. E2 returns four regions. F2 returns four totals. You edited no formula that uses #.
Finally, enter this in H2.
=SUM(F2#)It returns the grand total, 700. It stays correct after the new region appears.
How `#` behaves in edge cases
The anchor does not spill
If the cell you point at holds a plain value or a formula that returns a single result, E2# returns #REF!. Excel treats it as a reference to something that is not a spill range. The same happens if the cell is empty.
The anchor has a `#SPILL!` error
When a spill is blocked, the anchor shows #SPILL!. Excel has no spill range to describe, so E2# returns #REF!. Fix the blockage in the anchor first. Formulas that use E2# then recover on their own.
The spill grows into the formula's own cell
A formula that refers to its own spill range creates a circular reference. For example, putting =SUM(E2#) in E5 fails if E2 spills over E5. Place formulas that consume a spill outside the cells it occupies.
Spills that depend on each other
Chains such as E2 to G2 to I2 are fine. Excel calculates them in order. Be careful about two spills that each read the other, because that is a circular reference.
`#` compared with other ways to point at a result
| Approach | Tracks size changes | Notes |
|---|---|---|
| `E2:E9` | No | Breaks when the spill grows or shrinks |
| `E2:E100` | Partly | Covers growth but includes blanks, which can distort counts or averages |
| Excel table column such as `Table1[Name]` | Yes | Works for tables, not for formula results |
| `E2#` | Yes | Works only when `E2` is the anchor of a spill |
A large fixed range is a common workaround. It can cause wrong results. For example, AVERAGE ignores blank cells but ROWS(E2:E100) counts them. E2# avoids that problem.
Using `#` outside normal formulas
The same operator works in several other places in Excel.
- Named ranges. You can define a name with a refers-to value of
=Sheet1!$E$2#. The name then expands and contracts with the spill. - Data validation. A list rule can use
=$E$2#as its source, so the dropdown shows the current items. Later chapters cover this in more detail. - Charts. A chart series can point to a named range built on a spill reference. This gives a chart that resizes itself.
In validation and names, the anchor address is usually absolute ($E$2#), so it does not shift when the rule is copied.
Common errors and their causes
| Symptom | Likely cause | Fix |
|---|---|---|
| `#REF!` from `E2#` | The anchor does not spill, or is empty | Check the anchor formula and that it returns an array |
| `#REF!` from `E2#` while the anchor shows `#SPILL!` | A blocked spill has no range | Clear the cells in the way |
| Circular reference warning | The consuming formula sits inside the spill | Move it outside the spill area |
| Totals include extra zeros or blanks | A fixed oversize range was used | Switch to `E2#` |
| `#` is not accepted when typing | Older Excel version | Use Excel for Microsoft 365 or Excel 2021 or later |
Summary
E2#is a reference to the whole spill range anchored atE2.- It resizes automatically, so dependent formulas stay correct.
- It returns an array with the same shape as the spill, so you can pass it to any function that accepts arrays.
- It returns
#REF!when the anchor does not hold a working spill formula. - Keep the formulas that use it outside the spill area to avoid circular references.
Exercise
Cell B2 contains =UNIQUE(A2:A50), which currently spills 12 items. Write one formula that returns how many items the spill holds, and say what happens to that formula when the source data changes so that UNIQUE returns 15 items. Then say what B2# returns if you replace the formula in B2 with the number 5.
Show answer
Use =ROWS(B2#) (or =COUNTA(B2#) if no item is blank). When UNIQUE returns 15 items, the spill range grows to 15 cells, B2# covers all 15, and the formula returns 15 with no edit. If B2 is replaced by the plain number 5, B2 is no longer the anchor of a spill range, so B2# returns #REF!.
Exercise
A student puts =SUM(E2#) in E6, where E2 holds =SORT(UNIQUE(A2:A20)) and returns 8 values. What goes wrong, and where should the SUM go?
Show answer
The spill occupies E2:E9, so E6 is inside it. The formula would be in the way of the spill, which causes #SPILL! on E2, and a SUM that refers to the range containing itself is a circular reference. Move the SUM outside the spill area, for example to G2, where it cannot be overwritten or overlapped by the spill.