Excel dynamic arrays: FILTER, SORT, UNIQUE, SEQUENCE and the #SPILL! error
One formula, many results: how FILTER, SORT, UNIQUE and SEQUENCE spill, the E2# reference, and what causes #SPILL! and how to fix it (Excel 365/2021).
Since Excel 365 and Excel 2021, a formula can return several values at once. You write the formula in one cell, and the result spills into neighbouring cells down and to the right by itself. These are dynamic arrays.
Unique lists, sorted copies or conditional extracts used to require clunky formulas, Ctrl + Shift + Enter array formulas or manual copying. Now each of them is one short formula: =УНИК(B2:B7), =СОРТ(A2:C7;3;-1), =ФИЛЬТР(A2:C7;B2:B7="Tashkent"). Change the source and the result updates itself.
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Manager | City | Amount, mln | Cities | Sales, mln | ||
| 2 | Aziz | Tashkent | 4,5 | Bukhara | 9,1 | ||
| 3 | Dilnoza | Samarkand | 7,2 | Samarkand | 19,6 | ||
| 4 | Javohir | Tashkent | 6,8 | Tashkent | 15,2 | ||
| 5 | Malika | Bukhara | 9,1 | ||||
| 6 | Sardor | Samarkand | 12,4 | ||||
| 7 | Nodira | Tashkent | 3,9 | ||||
| 8 |
How spilling works
- The formula lives only in the top-left cell (E2). Select E3 or E4 and the formula bar shows it greyed out — these are “ghost” values that can’t be edited one by one.
- Excel outlines the result (the spill range) with a blue border.
- Add a new city to the source and the list grows; delete one and it shrinks. No need to fill anything down.
- To delete or change the result, touch only the formula in E2.
A unique sorted list — 3 steps
1
Type =УНИК(B2:B7) in E2 and press Enter. The list of cities without duplicates spills down — in the order they appear in the source.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Manager | City | Amount, mln | Cities | ||
| 2 | Aziz | Tashkent | 4,5 | Tashkent | ||
| 3 | Dilnoza | Samarkand | 7,2 | Samarkand | ||
| 4 | Javohir | Tashkent | 6,8 | Bukhara | ||
| 5 | Malika | Bukhara | 9,1 | |||
| 6 | Sardor | Samarkand | 12,4 | |||
| 7 | Nodira | Tashkent | 3,9 | |||
| 8 |
2
Wrap it in SORT: =СОРТ(УНИК(B2:B7)) — now the list is alphabetical: Bukhara, Samarkand, Tashkent.
3
Next to it, in F2, type =СУММЕСЛИ(B2:B7;E2#;C2:C7). E2# means “the whole spill range that starts in E2”. SUMIF is calculated for every city, spills too, and grows together with column E. The result is the picture at the top of the page.
The four core functions
=ФИЛЬТР(array; include; [if_empty])— the rows that meet a condition.=ФИЛЬТР(A2:C7;B2:B7="Tashkent";"None"). Several conditions: AND with*, OR with+:=ФИЛЬТР(A2:C7;(B2:B7="Tashkent")*(C2:C7>5)).=СОРТ(array; [sort_index]; [sort_order])— a sorted copy. Order: 1 ascending, -1 descending.=СОРТ(A2:C7;3;-1)— by amount, largest first.=УНИК(array; [by_col]; [exactly_once])— no duplicates. With TRUE as the third argument you get only the values that appear exactly once.=ПОСЛЕДОВ(rows; [columns]; [start]; [step])— a sequence of numbers.=ПОСЛЕДОВ(12)gives 1 to 12.
They nest easily: =СОРТ(ФИЛЬТР(...);3;-1) — “pick Tashkent and sort by amount”.
| A | B | C | D | E | F | G | H | |
|---|---|---|---|---|---|---|---|---|
| 1 | Manager | City | Amount, mln | Manager | City | Amount, mln | ||
| 2 | Aziz | Tashkent | 4,5 | Sardor | Samarkand | 12,4 | ||
| 3 | Dilnoza | Samarkand | 7,2 | Malika | Bukhara | 9,1 | ||
| 4 | Javohir | Tashkent | 6,8 | Dilnoza | Samarkand | 7,2 | ||
| 5 | Malika | Bukhara | 9,1 | Javohir | Tashkent | 6,8 | ||
| 6 | Sardor | Samarkand | 12,4 | Aziz | Tashkent | 4,5 | ||
| 7 | Nodira | Tashkent | 3,9 | Nodira | Tashkent | 3,9 | ||
| 8 |
| A | B | C | D | E | F | G | H | |
|---|---|---|---|---|---|---|---|---|
| 1 | Manager | City | Amount, mln | Manager | City | Amount, mln | ||
| 2 | Aziz | Tashkent | 4,5 | Aziz | Tashkent | 4,5 | ||
| 3 | Dilnoza | Samarkand | 7,2 | Javohir | Tashkent | 6,8 | ||
| 4 | Javohir | Tashkent | 6,8 | Nodira | Tashkent | 3,9 | ||
| 5 | Malika | Bukhara | 9,1 | |||||
| 6 | Sardor | Samarkand | 12,4 | |||||
| 7 | Nodira | Tashkent | 3,9 | |||||
| 8 |
| A | B | C | D | |
|---|---|---|---|---|
| 1 | No. | Manager | ||
| 2 | 1 | Aziz | ||
| 3 | 2 | Dilnoza | ||
| 4 | 3 | Javohir | ||
| 5 | 4 | Malika | ||
| 6 | 5 | Sardor | ||
| 7 | 6 | Nodira | ||
| 8 |
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Manager | City | Amount, mln | Cities | ||
| 2 | Aziz | Tashkent | 4,5 | #SPILL! | ||
| 3 | Dilnoza | Samarkand | 7,2 | old note1 | ||
| 4 | Javohir | Tashkent | 6,8 | |||
| 5 | Malika | Bukhara | 9,1 | |||
| 6 | Sardor | Samarkand | 12,4 | |||
| 7 | Nodira | Tashkent | 3,9 | |||
| 8 |
Other causes of #SPILL!
- Merged cells (Merge & Center) in the spill area — unmerge them.
- The formula sits inside an Excel Table. Dynamic arrays can’t spill inside Tables. Move the formula outside — the source can still be a Table.
- The result runs off the edge of the sheet or is too large (e.g.
=ПОСЛЕДОВ(2000000)). - The size keeps changing — for example, when the number of results depends on RANDBETWEEN.
A “related” error is #CALC! — FILTER returns it when nothing matches. Supply the third argument: =ФИЛЬТР(A2:C7;B2:B7="Khiva";"Not found").
Pro level: whole-column references, the @ sign and compatibility
Don’t reference whole columns. =УНИК(B:B) scans 1,048,576 rows and adds a 0 (from the empty rows) to the end of your list. Make the source a Table (Ctrl + T) or use an exact range — when the Table grows, so does the formula.
The @ sign means “one value”. So that an old formula like =B2:B7*2 doesn’t suddenly spill in 365, Excel displays it as =@B2:B7*2: @ takes the single value from the current row. Add @ yourself in a new formula and spilling is turned off.
Compatibility. Excel 2016/2019 have no FILTER, SORT, UNIQUE or SEQUENCE — such a file shows #NAME? there, and older array formulas appear as {=...}. Know who the file is going to.
Powerful combinations:
=СОРТ(УНИК(ФИЛЬТР(B2:B7;C2:C7>5)))— cities with sales over 5 mln, alphabetically.=СЧЁТЗ(УНИК(B2:B7))— how many distinct cities.=ПРОСМОТРX(E2#;A2:A7;C2:C7)— one lookup formula for an entire list.
Try it in the simulator
Type =СОРТ(УНИК(B2:B7)) in E2 and watch it spill. Then type =СОРТ(A2:C7;3;-1) in G2. Finally type any text in E3 — E2 shows #SPILL!; then clear E3.
| A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Manager | City | Amount, mln | Cities | Sorted | |||||||||||||||||||
| 2 | Aziz | Tashkent | 4,5 | |||||||||||||||||||||
| 3 | Dilnoza | Samarkand | 7,2 | |||||||||||||||||||||
| 4 | Javohir | Tashkent | 6,8 | |||||||||||||||||||||
| 5 | Malika | Bukhara | 9,1 | |||||||||||||||||||||
| 6 | Sardor | Samarkand | 12,4 | |||||||||||||||||||||
| 7 | Nodira | Tashkent | 3,9 | |||||||||||||||||||||
| 8 | ||||||||||||||||||||||||
| 9 | ||||||||||||||||||||||||
| 10 | ||||||||||||||||||||||||
| 11 |
Has ExcelLab been useful?
Support the project and help us release new lessons and exercises.