Excel tutorial
/

Data analysis

Advanced

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.

Книга1 - Excel
—☐✕
E2fx=СОРТ(УНИК(B2:B7))
ABCDEFG
1ManagerCityAmount, mlnCitiesSales, mln
2AzizTashkent4,5Bukhara9,1
3DilnozaSamarkand7,2Samarkand19,6
4JavohirTashkent6,8Tashkent15,2
5MalikaBukhara9,1
6SardorSamarkand12,4
7NodiraTashkent3,9
8
ГотовоКоличество: 3
One formula in E2 spilled into three cells. F2 holds =SUMIF(B2:B7,E2#,C2:C7) — it spills along with column E

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.

Книга1 - Excel
—☐✕
E2fx=УНИК(B2:B7)
ABCDEF
1ManagerCityAmount, mlnCities
2AzizTashkent4,5Tashkent
3DilnozaSamarkand7,2Samarkand
4JavohirTashkent6,8Bukhara
5MalikaBukhara9,1
6SardorSamarkand12,4
7NodiraTashkent3,9
8
ГотовоКоличество: 3

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”.

Книга1 - Excel
—☐✕
E2fx=СОРТ(A2:C7;3;-1)
ABCDEFGH
1ManagerCityAmount, mlnManagerCityAmount, mln
2AzizTashkent4,5SardorSamarkand12,4
3DilnozaSamarkand7,2MalikaBukhara9,1
4JavohirTashkent6,8DilnozaSamarkand7,2
5MalikaBukhara9,1JavohirTashkent6,8
6SardorSamarkand12,4AzizTashkent4,5
7NodiraTashkent3,9NodiraTashkent3,9
8
ГотовоСреднее: 7,3167Количество: 18Сумма: 43,9
=SORT(A2:C7,3,-1): the whole table sorted by amount, descending — 3 columns × 6 rows from one formula
Книга1 - Excel
—☐✕
fx
ABCDEFGH
1ManagerCityAmount, mlnManagerCityAmount, mln
2AzizTashkent4,5AzizTashkent4,5
3DilnozaSamarkand7,2JavohirTashkent6,8
4JavohirTashkent6,8NodiraTashkent3,9
5MalikaBukhara9,1
6SardorSamarkand12,4
7NodiraTashkent3,9
8
Готово
E2 holds =FILTER(A2:C7,B2:B7="Tashkent") — Tashkent rows only. A new Tashkent order in the source extends the list automatically
Книга1 - Excel
—☐✕
A2fx=ПОСЛЕДОВ(СЧЁТЗ(B2:B7))
ABCD
1No.Manager
21Aziz
32Dilnoza
43Javohir
54Malika
65Sardor
76Nodira
8
ГотовоСреднее: 3,5Количество: 6Сумма: 21
=SEQUENCE(COUNTA(B2:B7)) — row numbers adjust to the length of the list
Книга1 - Excel
—☐✕
fx
ABCDEF
1ManagerCityAmount, mlnCities
2AzizTashkent4,5#SPILL!
3DilnozaSamarkand7,2old note1
4JavohirTashkent6,8
5MalikaBukhara9,1
6SardorSamarkand12,4
7NodiraTashkent3,9
8
Готово
E2 holds =SORT(UNIQUE(B2:B7)), but leftover text in E3 blocks the way — #SPILL!

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.

Книга1 - Excel
—☐✕
Буфер обмена
Шрифт
Выравнивание
Число
Стили
Ячейки
Редактирование
✕✓fx
ABCDEFGHIJKLMNOPQRSTUVWX
1ManagerCityAmount, mlnCitiesSorted
2AzizTashkent4,5
3DilnozaSamarkand7,2
4JavohirTashkent6,8
5MalikaBukhara9,1
6SardorSamarkand12,4
7NodiraTashkent3,9
8
9
10
11
Лист1
Готово

Has ExcelLab been useful?

Support the project and help us release new lessons and exercises.

Support us
Previous

56 / 154