Sub topic 6
Referring to a whole spill range with #
This chapter assumes you can enter and edit formulas, use relative and absolute references, and use basic functions such as SUM. You also need Excel for Microsoft 365 or Excel 2021 or later. You should know that a formula in one anchor cell can spill results into neighboring cells.
Why a normal reference breaks
A spill range changes size when its source data changes. A reference such as E2:E6 is fixed. If the spill later grows to E2:E9, the reference still covers only five rows. If it shrinks, the reference can include empty cells.
The spill range operator # solves this. You put it after the anchor cell address. E2# means the whole spill range that the formula in E2 currently produces.
Using the # operator
Suppose E2 holds =SORT(UNIQUE(A2:A20)). The unique, sorted values spill down from E2. To add up a spilled list of numbers, write this in another cell:
=SUM(E2#)The sum covers the whole current spill range. When the source data changes and the spill grows or shrinks, the result updates without any edit to the formula.
You can use # anywhere a range is accepted. For example, =COUNTA(E2#) counts the spilled items. =SORT(E2#,1,-1) sorts them in descending order.
Worked example
Here is a small chain of formulas. Each step refers to the previous spill with #.
- In D2, enter
=SEQUENCE(5). The numbers 1 to 5 spill down D2:D6. - In E2, enter
=D2#^2. The squares 1, 4, 9, 16 and 25 spill down E2:E6. - In G2, enter
=SUM(E2#). The result is 55.
If you change D2 to =SEQUENCE(8), both spills grow. G2 then returns 204 with no further edits.
=SEQUENCE(8)=D2#^2=SUM(E2#)Rules to remember
#works only on a cell that holds a spilling formula. The anchor cell is the top-left cell of the spill.- If the cell holds a normal value or a formula that returns a single value,
E2#returns a#REF!error. - You can type the
#yourself, or select the spill range with the mouse and Excel writes it for you. - If the spilling formula returns
#SPILL!, there is no spill range to refer to. Fix the blockage first.
Where # is useful
The operator is most helpful when the number of results is not known in advance. Typical uses are totals of a FILTER result, counts of unique values, and lookups against a spilled list. It also keeps formulas readable, because E2# says what you mean. A range such as E2:E40 only guesses at the size.
Exercise
Cell B2 holds =FILTER(A2:A20,A2:A20>50), which spills down. Write a formula that counts how many values the filter returns. Explain why it is better than =COUNT(B2:B10).
Show answer
Use =COUNT(B2#). The # follows the current size of the spill. B2:B10 is fixed, so it misses values if the spill grows beyond row 10.
Exercise
A cell contains =D2# but shows #REF!. D2 contains the number 7. What is the cause?
Show answer
D2 is not the anchor of a spill range, because it holds a single value. # needs a cell with a spilling formula.