Sub topic 13
Fixing #SPILL!: blocked dynamic array results
This chapter assumes you can enter and edit formulas, use cell references and ranges such as A2:A10, and use basic functions such as SUM and VLOOKUP. It also assumes you use a version of Excel with dynamic arrays (Microsoft 365, Excel 2021 or later, or Excel for the web).
What a spill is
A dynamic array formula is a formula that can return more than one value. You type it in one cell, and Excel writes the results into the cells below and to the right. This behavior is called spilling. The range the results occupy is the spill range.
=UNIQUE(A2:A20)If you enter this in D2 and the list holds five distinct values, the results fill D2:D6. Only D2 contains the formula. Cells D3:D6 display results, and Excel draws a thin blue border around the spill range when you select any cell in it.
Excel returns #SPILL! when it cannot write the results into the spill range. The formula itself is usually correct. Something on the sheet is in the way, or Excel cannot work out how big the result will be.
Reading the #SPILL! message
Select the cell that shows #SPILL!. A warning icon appears beside it. Open its menu to see the specific cause. For the most common cause, the menu offers Select Obstructing Cells, which highlights whatever is in the way.
The causes below are the ones you will meet most often.
| Cause shown in the menu | What is wrong | Typical fix |
|---|---|---|
| Spill range isn't blank | A cell in the target area holds a value, a formula, or invisible content | Clear or move the blocking cell |
| Spill range has merged cells | A merged cell lies in the target area | Unmerge the cells |
| Table formulas don't support spilled arrays | The formula is inside an Excel table | Move the formula outside the table |
| Spill range is too big | The result would run past the edge of the worksheet | Reference a bounded range, or move the formula |
| Unknown spill size | Excel cannot determine the result size, often because of a volatile function | Use fixed sizes, or restructure the formula |
| Out of memory | The result is too large for Excel to calculate | Reduce the input or the result size |
Cause 1: the spill range isn't blank
This is the most common cause. Suppose =UNIQUE(A2:A20) is in D2 and the result needs D2:D6. If D4 already contains a number, Excel will not overwrite it. D2 shows #SPILL!.
To fix it:
- Select D2 and open the warning menu.
- Choose Select Obstructing Cells. Excel highlights D4.
- Delete the content of D4, or move it elsewhere. The formula recalculates and the results appear.
Some blockers are hard to see:
- A formula that returns an empty string (
="") looks blank but still occupies the cell. - A cell containing only a space looks blank. This often comes from pasted data.
- Text can be formatted with white font, so it is invisible against the background.
- A note or label that sits far below the formula, but within the range the result needs, still blocks it.
Select Obstructing Cells finds all of these. Use it instead of hunting by eye.
=SEQUENCE(5)This formula needs exactly five cells. If you place it in F1 and anything sits in F2:F5, it fails. Clear those cells and it fills F1:F5 with 1 to 5.
Cause 2: merged cells
A spill range cannot include merged cells. If a merged header or label lies within the area the formula needs, you get #SPILL!.
Select the obstructing cells, then use Home > Merge & Center (the toggle) to unmerge them. If the merged layout matters for appearance, move the formula so its spill range avoids those cells. A different location is better than merging after the fact, because merging inside a spill range breaks the formula again.
Cause 3: the formula is in a table
Excel tables do not support dynamic array formulas that spill. If you type =UNIQUE(...) or =FILTER(...) in a table cell, Excel returns #SPILL!.
You have two options:
- Move the formula to a cell outside the table.
- Convert the table to a plain range (Table Design > Convert to Range) if you do not need table features.
If you need a single value inside a table, use a function that returns one result. For example, =INDEX(UNIQUE(A2:A20),1) returns only the first unique value, so it does not need to spill.
Cause 4: the result is too large or its size is unknown
The spill range is too big when the result would run off the sheet. A typical case is a whole-column reference:
=A:A*2Entered anywhere other than row 1, this tries to return more than a million rows and fails. Reference a bounded range such as =A2:A100*2, or an Excel table column, instead.
Unknown spill size appears when the size of the result depends on something Excel cannot settle before calculation, such as volatile functions like OFFSET, INDIRECT or RANDARRAY inside the argument that sets the size. Rewrite the formula to use fixed sizes. For example, =RANDARRAY(5,2) has fixed dimensions and spills normally.
Out-of-memory errors are rare. They occur when a formula builds an enormous array. Narrow the input range, or filter first and compute afterward.
Diagnosis flow
Working with spilled results
Once a formula spills, you can refer to the whole result with the spill range operator, #, placed after the anchor cell (the top-left cell that holds the formula):
=SUM(D2#)This sums everything in the spill range that starts at D2. The reference grows or shrinks when the spill changes size, so you do not need to adjust it by hand. If D2 does not contain a spilling formula, the reference returns #REF!.
Another useful form is a filter that handles the "no matches" case without producing an error:
=FILTER(A2:B20,B2:B20>100,"No matches")The third argument is returned when nothing matches. Without it, FILTER returns #CALC!. This is a different error from #SPILL!, and it has a different fix.
The @ operator and older versions
When you open a workbook in a version of Excel that does not support dynamic arrays, formulas that could return several values appear with a leading @ or as legacy array formulas. The @ is the implicit intersection operator. It tells Excel to return a single value. You may see it added automatically to formulas that were written before dynamic arrays existed. Remove it if you want the formula to spill.
If you share a workbook with someone on an older version, they will see the formula but not the spill. Plan for this if the workbook has multiple users.
Do not mask #SPILL! with IFERROR
It is tempting to wrap a blocked formula in IFERROR:
=IFERROR(UNIQUE(A2:A20),"")This hides the problem instead of solving it. The formula still cannot spill, and now the cell looks empty, so the list quietly disappears. IFERROR is useful for expected errors such as a lookup that finds nothing. A #SPILL! is a layout problem, and you should fix the layout.
Prevent spill errors by design
- Leave empty space below and to the right of every spilling formula. Put a dynamic array at the top of a column with nothing underneath, or give it its own area.
- Keep titles and notes beside the spill range, not under it.
- Put each dynamic array formula in its own column when results may grow, so one list cannot run into another.
- Use
#references in dependent formulas so they follow the spill when it resizes. - Avoid dynamic array formulas inside tables and merged areas.
Exercise
In D2 you enter =SORT(A2:A12) and get #SPILL!. D2:D12 appear empty, but when you select D7 the formula bar shows ="". What is the cause, and how do you fix it?
Show answer
D7 contains a formula that returns an empty string. It looks blank but is not an empty cell, so it blocks the spill range. Open the warning menu on D2, choose Select Obstructing Cells, and delete the formula in D7. The SORT formula then spills into D2:D12.
Exercise
You write =UNIQUE(A2:A20) in a cell inside an Excel table and see #SPILL!. Give two ways to fix it.
Show answer
Move the formula to a cell outside the table, or convert the table to a normal range with Table Design > Convert to Range. A third option is to replace the formula with one that returns a single value, such as =INDEX(UNIQUE(A2:A20),1).