Applies ToExcel for Microsoft 365 Excel for Microsoft 365 for Mac Excel for the web Excel 2024 Excel 2024 for Mac Excel 2021 Excel 2021 for Mac Excel 2019 Excel 2016 Excel for iPad Excel for iPhone Excel for Android tablets Excel for Android phones

Excel formulas that return a set of values, also known as an array, return these values to neighboring cells. This behavior is called spilling.

Formulas that can return arrays of variable size are called dynamic array formulas. Formulas that are currently returning arrays that are successfully spilling can be referred to as  spilled array formulas. 

Following are some notes to help you understand and use these type of formulas. 

What does spill mean?

Older array formulas, known as legacy array formulas, always return a fixed-size result - they always spill into the same number of cells. The spilling behavior described in this topic does not apply to legacy array formulas.

Spill means that a formula has resulted in multiple values, and those values have been placed in the neighboring cells. For example, =SORT(D2:D11,1,-1), which sorts an array in descending order, would return a corresponding array that's 10 rows tall. But you only need to enter the formula in the top left cell, or F2 in this case, and it will automatically spill down to cell F11.

Sort the values in cells D2:D11 with =SORT(D2:D11,1,-1)

Key points

  • When you press Enter to confirm your formula, Excel will dynamically size the output range for you, and place the results into each cell within that range.

  • If you are writing a dynamic array formula to act on a list of data, it can be useful to place it in an Excel table, then use structured references to refer to the data. This is because structured references automatically adjust as rows are added or removed from the table.

  • Spilled array formulas are not supported in Excel tables themselves, so you should place them in the grid outside of the Table. Tables are best suited to holding rows and columns of independent data.

  • Once you enter a spilled array formula, when you select any cell within the spill area, Excel will place a highlighted border around the range. The border will disappear when you select a cell outside of the area.

    Array formula with the output range highlighted with a blue border

  • Only the first cell in the spill area is editable. If you select another cell in the spill area, the formula will be visible in the formula bar, but the text is "ghosted", and can't be changed. If you need to update the formula, you should select the top-left cell in the array range, change it as needed, then Excel will automatically update the rest of the spill area for you when you press Enter.

    Image of a ghosted array formula, meaning it's not editable, since it's not the first cell in the array range

  • Formula overlap - Array formulas can't be input if there is anything blocking the output range. and if this happens, Excel will return a #SPILL! error indicating that there is a blockage. If you remove the blockage, the formula will spill as expected. In the example below, the formula's output range overlaps another range with data, and is shown with a dotted border overlapping cells with values indicating that it can't spill. Remove the blocking data, or copy it somewhere else, and the formula will spill as expected.

    Image of a #SPILL! error indicating that an array formula output is experiencing a blockage that prevents it from spilling.

  • Legacy array formulas entered via CTRL+SHIFT+ENTER (CSE) are still supported for back compatibility reasons, but should no longer be used. If you like, you can convert legacy array formulas to dynamic array formulas by locating the first cell in the array range, copy the text of the formula, delete the entire range of the legacy array, and then re-enter the formula in the top left cell. Before upgrading legacy array formulas to dynamic array formulas, you should be aware of some calculation differences between the two.

  • Excel has limited support for dynamic arrays between workbooks, and this scenario is only supported when both workbooks are open. If you close the source workbook, any linked dynamic array formulas will return a #REF! error when they are refreshed.

Need more help?

You can always ask an expert in the Excel Tech Community or get support in Communities.

See Also

FILTER function

RANDARRAY function

SEQUENCE function

SORT function

SORTBY function

UNIQUE function

#SPILL! errors in Excel

Implicit intersection operator: @

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.