Sub topic 3
How a formula spills into neighboring cells
This chapter assumes you can enter and edit formulas, use ranges such as B2:B6, and read relative and absolute references. It also assumes you have Excel for Microsoft 365 or Excel 2021 or later. Older versions don't spill. Chapter 1 covered the calculation engine. This chapter covers what the engine does when a formula returns more than one value.
One formula, many cells
In older Excel, a formula returned one value to one cell. To get five results you wrote a formula and filled it down five rows.
In dynamic-array Excel, a formula can return an array, which is a rectangular block of values. When the result has more than one value, Excel writes the values into the cells next to the formula. This is called spilling, and the block of cells that receives the values is the spill range.
Try the simplest case. Enter this in an empty cell, such as A1:
=SEQUENCE(5)Excel shows 1 in A1 and fills A2 to A5 with 2 to 5. You typed one formula in one cell. The cell that holds the formula is the anchor. The cells below it only display values from the anchor's result.
SEQUENCE takes up to four arguments: rows, columns, start and step. With two arguments you get a grid:
=SEQUENCE(3,4)This fills 3 rows and 4 columns with 1 to 12, counting across each row first.
Why ranges produce arrays
Spilling usually starts with arithmetic on ranges. In the old engine, a formula such as =B2:B6*C2:C6 entered in one cell silently took the one value from its own row. This is called implicit intersection. The dynamic-array engine doesn't do that. It multiplies the two ranges item by item and returns all five results.
Suppose you have this order data:
| Row | B (Quantity) | C (Unit price) |
|---|---|---|
| 2 | 3 | 10 |
| 3 | 5 | 4 |
| 4 | 2 | 25 |
| 5 | 10 | 3 |
| 6 | 1 | 40 |
Enter this in D2:
=B2:B6*C2:C6D2 to D6 now show 30, 20, 50, 30 and 40. There is no fill-down, and no $ references are needed to keep the ranges aligned.
Operators work this way, and so do most functions that accept a range. Wrapping the result in a function that returns a single value collapses it again. For example, =SUM(B2:B6*C2:C6) returns one number (170), so it doesn't spill.
What you can and can't do with spilled cells
The anchor owns the formula. The other cells only hold results, and this has practical effects:
- Click a spilled cell other than the anchor. The formula bar shows the formula in gray. You can read it, but you can't edit it from there.
- Typing a value into a spilled cell doesn't overwrite one result. The new value blocks the spill, and the anchor shows
#SPILL!. - Deleting the anchor clears the whole spill range. Deleting a single spilled cell has no effect, because the anchor writes it again.
- Copying the anchor copies the formula, and the copy spills in its new location. Copying a spilled cell and pasting it as values gives you plain values.
- Excel draws a thin blue border around the spill range when you select any cell in it. Use this to see its size.
The spill range resizes itself
Because the formula runs again whenever its inputs change, the spill range can grow and shrink. Put a count in F1 and use it as the row count:
=SEQUENCE(F1)If F1 is 3, the formula returns 1, 2, 3. Change F1 to 8 and the list extends to 8 rows. Change it to 2 and the cells below clear themselves. You never insert or delete rows by hand.
Cells that refer to a changing spill range can use the # operator to track it. A later chapter covers that operator, so it isn't needed here.
Shape of the result
The shape of the array decides which cells are used. The anchor is always the top-left cell.
| Result shape | Example formula | Cells filled from anchor A1 |
|---|---|---|
| One value | `=SUM(B2:B6)` | A1 only |
| Column | `=SEQUENCE(5)` | A1:A5 |
| Row | `=SEQUENCE(1,5)` | A1:E1 |
| Grid | `=SEQUENCE(3,4)` | A1:D3 |
Spilling goes down and to the right only. It never goes up or left. If you need a result above a source range, put the formula in a cell above it.
Combining a column and a row
Arithmetic between a column and a row doesn't pair items one by one. Excel expands both into a grid. This is called broadcasting. With numbers 1 to 3 in A2:A4 and 1 to 3 in B1:D1, this formula in B2 returns a 3 by 3 multiplication table:
=A2:A4*B1:D1Row 1 of the grid takes A2 times each value in B1:D1, row 2 takes A3, and so on. This is useful for lookup grids and cross tabulations, but it surprises people who expected a single column.
Arrays of different sizes
When two arrays have the same orientation but different lengths, Excel can't pair every item. The missing positions return #N/A:
=B2:B6*C2:C4This returns five rows. The first three are products, and the last two show #N/A because C5 and C6 aren't in the second range. Excel still spills all five rows. A wrong-sized range gives you wrong values, not a #SPILL!. Check range sizes first when a spill contains unexpected #N/A errors.
Cases where a spill can't happen
Excel checks the full target area before it writes anything. If any target cell is occupied, the anchor shows #SPILL! and no result appears. Common causes:
- A cell in the target area contains a value or formula, even a space character.
- The result would run past the edge of the worksheet.
- The anchor is inside an Excel table. Tables don't support spilling formulas.
- The spill range includes merged cells.
Clearing the blocking cell lets the formula spill at once, with no re-entry needed. A later chapter covers #SPILL! in depth.
Spilling compared with older approaches
You may open workbooks that were built before spilling existed. These behave differently:
| Approach | Where the formula lives | Resizes automatically? |
|---|---|---|
| Fill-down formula | Every cell has its own copy | No, you fill down again |
| Legacy Ctrl+Shift+Enter array formula | One formula across a fixed block, shown with braces | No, the block size is fixed |
| Dynamic array formula | Anchor cell only | Yes |
Fill-down formulas are still the right choice when each row needs independent edits or comments. Spilling suits calculations where all rows follow the same rule, and where the number of rows changes.
Troubleshooting checklist
When a formula doesn't spill as you expect, check these in order:
- Does the result have more than one value? A function such as
SUMorCOUNTreturns one. - Is anything in the cells below or to the right of the anchor?
- Is the anchor in an Excel table or next to merged cells?
- Do the input ranges have matching sizes?
- Are you in Excel for Microsoft 365 or Excel 2021 or later? Older versions show the formula with an
@or as a legacy array.
Summary
A spilling formula lives in one anchor cell. Excel evaluates it, measures the array it produced, and writes the values down and to the right if the cells are free. The spill range follows the formula's inputs, so it grows and shrinks on its own, and only the anchor can be edited.
Exercise
In D2 you enter =B2:B6*C2:C4, where B2:B6 holds five quantities and C2:C4 holds only three prices. Cells D3 to D8 are empty. What does the sheet show, and what changes if you type the number 9 into D4?
Show answer
Excel spills five rows into D2:D6. The first three rows show quantity times price, and the last two show #N/A because the second range has no matching items. Typing 9 into D4 blocks the spill range, so the anchor D2 shows #SPILL! and the spilled values disappear. Clearing D4 makes the formula spill again.
Exercise
You want a 4 by 6 grid that counts from 1 across each row. Which formula do you enter, and which cell does it use as the anchor?
Show answer
Enter =SEQUENCE(4,6) in one cell. That cell is the anchor, and it is the top-left cell of the grid. The other 23 cells show the result.