Working with Excel Dynamic Arrays
A practical guide to Excel dynamic arrays: how formulas spill into worksheet cells, how to shape results with common array functions, and how to check calculations for errors and compatibility.
How spilling works
A can return one value or several values from a single formula. When it returns several, Excel places them in neighboring cells automatically; this is called spilling. Enter the formula in the top-left cell of the intended output area and leave enough empty space below and beside it. The adjusts when the result changes.
For example, if a formula is entered in G2, its results may fill cells below and beside G2. If you want to refer to that changing output elsewhere, use the spill operator #: =COUNTA(G2#) counts the values in the beginning at G2.
Keep spill formulas in ordinary worksheet cells, outside an Excel Table. A table can still provide structured-reference data, such as the Sales table used in the examples in this lesson, but a formula inside a table cannot spill. If an occupied cell blocks the intended output, Excel reports #SPILL!; clear the blocking cell or move it, then check that the output fits the available space.
Dynamic arrays are supported in current Excel versions, including Microsoft 365 and Excel 2021 or later, but function availability varies by version.
, , and find distinct values
The functions in this section select, order, or reduce repeated data. Because each can return multiple values, place its formula in a clear spill area outside an Excel Table.
Select matching rows with
returns rows that meet a condition. With the Sales table, this formula returns East-region sales:
=FILTER(Sales,Sales[Region]="East","No matching rows")
The third argument, "No matching rows", specifies what to return when the condition finds no rows. If you omit it, an empty result can produce #CALC!.
You can combine conditions. Use * for AND: both conditions must be met. This example returns East-region rows where Units is at least 10:
=FILTER(Sales,(Sales[Region]="East")*(Sales[Units]>=10),"No matching rows")
Use + for OR: a row can meet either condition. In each case, the conditions are evaluated for the rows, and the combined result determines which rows returns.
Order results with or SORTBY
orders an array using a column index. SORTBY orders an array using one or more corresponding ranges, which is useful when you want to specify keys directly. For example:
=SORTBY(Sales,Sales[Region],1,Sales[Units],-1)
This sorts the Sales table by Region in ascending order, then by Units in descending order. The second key is applied within the ordering established by the first.
Functions can also be nested. For example, ((...)) first selects the matching rows and then sorts the resulting array. The order matters: the sorting is applied to the filtered results, not to the full original array.
Return distinct values with
returns distinct values. To make an alphabetized list of the distinct regions in Sales, nest inside :
=SORT(UNIQUE(Sales[Region]))
Here, removes repeated region values; then orders the distinct list alphabetically.
Combine arrays
and combine arrays in different directions. Use to append one array below another; for example, =(EastSales,WestSales) combines two regional lists vertically. Use to place arrays side by side.
Check array dimensions before combining them. A vertical stack with different numbers of columns, or a horizontal stack with different numbers of rows, leaves positions without corresponding values. Excel fills those positions with #N/A. Use arrays with compatible dimensions where possible, or deliberately account for the padding errors in the resulting formula.
Test and document the result
After entering a , check that the spill border surrounds the expected output and that no error values appear. If Excel reports #SPILL!, look for an occupied cell blocking the output. For other unexpected errors, review the formula and its assumptions, including the dimensions of arrays being combined.
Test behavior as well as appearance: try a condition that returns no matching rows, and add or change a row in the source table to confirm that the output updates as expected. For a formula, also check that its no-match result is appropriate—or, if no result was specified, be aware that an empty result can produce #CALC!.
Document the formula’s purpose, the source table and columns it uses, its criteria, and any assumptions about empty results. If you share the workbook, check that recipients’ Excel versions support the functions in the formula. Dynamic-array support and function availability vary by version, and older Excel versions may not calculate these formulas correctly.
: A review of a dynamic-array calculation to confirm its output and document its assumptions.