The short answer
Add # after the cell that holds a spilling formula to refer to its whole spill range. If D2 holds =UNIQUE(A2:A100), then D2# refers to every value the formula currently shows:
=SUM(D2#)
The reference resizes on its own when the spill range grows or shrinks.
Why a fixed range isn’t enough
You could write D2:D20 instead, but that range stays the same size. If the result grows past row 20, the extra values are missed. If the result shrinks, the range picks up blank cells. The # reference follows the result, so the formula always covers what’s there.
Examples
Count each distinct value. If you built the list in D2 with an excel formula to remove duplicates, put this in E2 to count how often each value appears:
=COUNTIF(A2:A100, D2#)
E2 spills a count beside each value in the unique list. The counts line up with D because both spill from row 2. For more on counting distinct values, see how to count unique values in excel.
Total a filtered list. Suppose G2 holds =FILTER(B2:B100, C2:C100=“Paid”), which returns the amounts marked Paid. Then:
=SUM(G2#)
adds up all of them. Compare that with =SUM(G2), which adds only the first value in the spill.
Count the items. =ROWS(G2#) returns how many values the spill holds right now.
Sort a spilled list. =SORT(D2#) sorts the unique list from D2. The original list in D2 stays as it was.
Common mistakes
- Leaving off the #. =SUM(G2) adds only the cell that holds the formula, which is the first value. This is the most common reason a total looks too small.
- Using a fixed range. A range such as D2:D20 doesn’t grow with the result. Use D2# when the list can change size.
- A blocked spill. If the formula shows #SPILL!, there’s no full range to refer to. Clear the blocking cells first. How to fix #spill error in excel explains the steps.
What the anchor cell must hold
The cell before the # must hold a formula that spills. A reference to a cell that doesn’t spill won’t give you a list. If the result isn’t what you expected, check the anchor cell first.
Excel only
The # operator is an Excel feature. Google Sheets doesn’t have it, so in Sheets you work with the filled range directly.
If you want to count rows that match one condition rather than each unique value, how to use countif in excel covers that case, and D2# works inside it the same way.