Everything You Need to Know About Array Constants in Excel

Array constants in Microsoft Excel are powerful tools for performing multiple calculations with a single formula. Using array constants in your Excel worksheets avoids the need for lengthy or repeated formulas and eliminates the risk of accidental data changes.

People unfamiliar with array constants often find them daunting due to their unusual syntax and the need for a special symbol to enter them. So, in this guide, I’ll strip them back to their bare bones and show you how to use them in real-world scenarios. By the end, you’ll be an array constant expert!

OS

Windows, MacOS, iPhone, iPad, Android

Brand

Microsoft

Microsoft 365 includes access to Office apps like Word, Excel, and PowerPoint on up to five devices, 1 TB of OneDrive storage, and more.


Array Constants in Excel: Definition

An array constant is a hard-coded set of static values entered into a formula, enclosed in curly braces. In a straightforward example, typing:

={10,20,30,40}

into cell A1 and pressing Enter returns a dynamic array of 10 in cell A1, 20 in cell B1, 30 in cell C1, and 40 in cell D1.

A formula containing an array constant is entered into cell A1 in Excel, resulting in 10, 20, 30, and 40 appearing in cells A1 to D1.

In the example above, the dynamic array result is spilled horizontally (in columns) because commas are used between each value in the array constant.

A dynamic array is an array that extends from the cell where the formula is typed into adjacent cells—also known as spilling. While array constants are static sets of values, they can become part of a dynamic array when used in a formula with this spill behavior.

On the other hand, using semicolons between the values in the array constant returns a vertical dynamic array (in rows):

={10;20;30;40}
A formula containing an array constant is entered into cell A1 in Excel, resulting in 10, 20, 30, and 40 appearing in cells A1 to A4.

You can also combine commas and semicolons in an array constant to return a two-dimensional dynamic array:

={10,20;30,40}
A formula containing an array constant is entered into cell A1 in Excel, resulting in 10, 20, 30, and 40 appearing in cells A1 to B2.

Array Constants Work Differently Than They Used To

One-off versions of Excel from 2021 onward, Excel for Microsoft 365, and Excel for the web all support dynamic array formulas. This means that when you type an array constant in a formula that expects multiple values and press Enter, the result spills into the adjacent cells, with only the top-left cell containing a formula.

However, in older versions of Excel that don’t support dynamic array formulas, you need to select all the cells where you want the results to be displayed, type the formula, and press Ctrl+Shift+Enter to commit it. At this point, the same formula appears in all the cells you selected. This is known as a CSE or legacy array formula.

All the examples used in this article refer to array constants in versions of Excel that support dynamic array formulas.

OS

Windows, MacOS, iPhone, iPad, Android

Free trial

1 month

Microsoft 365 includes access to Office apps like Word, Excel, and PowerPoint on up to five devices, 1 TB of OneDrive storage, and more.


Using Array Constants With Excel Functions

Array constants are most useful in Excel when paired with functions, as they save you from having to input multiple or lengthy formulas. Here are two example scenarios.

SUM and COUNTIF: Counting How Many Values in an Array Meet Multiple Criteria

Imagine you have this Excel table, named T_TaskLog, and you want to find out the number of tasks whose status is Complete, Pending, or Pitched.

An Excel table, with task numbers in column A, and task statuses in column B.

To do this without array constants, you might type the following formula (divided onto separate lines for easier reading):

=COUNTIF(T_TaskLog[Status],"Complete")
+
COUNTIF(T_TaskLog[Status],"Pending")
+
COUNTIF(T_TaskLog[Status],"Pitched")

where the results of three separate COUNTIF formulas are added together using the plus (+) operator.

Three COUNTIF formulas in Excel combined with the plus symbol to assess for multiple criteria.

However, this formula is lengthy and difficult to parse. Instead, you can use array constants to group all the criteria into one argument. First, type the function’s name, an opening parenthesis, and the range to evaluate, followed by a comma:

=COUNTIF(T_TaskLog[Status],

Now, for the criteria, you need to enter all three status values as an array constant, enclosed in curly braces. Then, add a closing parenthesis, and press Enter:

=COUNTIF(T_TaskLog[Status],{"Complete","Pending","Pitched"})

At this point, Excel returns three separate results as a dynamic array—3 for Complete, 2 for Pending, and 2 for Pitched. That’s because you haven’t yet told Excel to add the results together.

An array constant used in an Excel formula to count the number of times the words 'Complete,' 'Pending,' and 'Pitched' appear in a table column.

To fix this, wrap the whole formula inside the SUM function and press Enter:

=SUM(COUNTIF(T_TaskLog[Status],{"Complete","Pending","Pitched"}))
A COUNTIF formula containing an array constant in Excel is wrapped inside the SUM function to add the three separate results together.

So, rather than using three separate COUNTIF formulas separated by the plus sign to count the three text criteria, the array constant forces Excel to perform the calculation three times—one for each criterion—and add the results together through the SUM function.

LARGE: Finding the Top x Values in a Range

In this example, let’s say you want to return the top three profits from the table, named T_Profits, as a separate array.

An Excel table, with shop IDs in column A and profits in column B. To the right of the table is an area where the top three profits will be extracted.

One way to do this is to use the LARGE function in three separate cells.

Typing this formula into cell E2 returns the largest value in the Profit column:

=LARGE(T_Profits[Profit],1)

Then, typing this formula into cell E3 returns the second largest value:

=LARGE(T_Profits[Profit],2)

Finally, typing this formula into cell E4 returns the third largest value:

=LARGE(T_Profits[Profit],3)
The LARGE function in Excel is used three times to extract the top three profits from an Excel table.

You can then use the XLOOKUP function to retrieve the IDs of the shops where these three highest profits were made:

=XLOOKUP(E2:E4,T_Profits[Profit],T_Profits[Shop])
The XLOOKUP function is used in Excel to return the shop ID of the three shops with the largest profits.

However, typing three separate, unlinked formulas takes time and is prone to error. Instead, you can use an array constant with the LARGE function to achieve the same result with a single formula:

=LARGE(T_Profits[Profit],{1;2;3})

This formula applies the LARGE function three times—the first time to return the largest value, the second time to return the second largest value, and the third time to return the third largest value—and returns the three results as a vertical dynamic array because a semicolon is used between each number in the array constant.

An array constant used in a LARGE Excel formula to return the top three profit from a column in a table.

Similarly, if you want to sum the largest three profits without using array constants, you would need to input the LARGE function three times, separated by the plus sign:

=LARGE(T_Profits[Profit],1)+LARGE(T_Profits[Profit],2)+LARGE(T_Profits[Profit],3)
Three LARGE formulas added together in Excel to return the sum of the three largest profits.

However, using an array constant with the SUM function makes the formula much tidier:

=SUM(LARGE(T_Profits[Profit],{1,2,3}))
An array constant is used as the second argument of the LARGE function, nested inside the SUM function, to return the sum of the top three profits.

What’s more, if you wanted to include the fourth largest profit in the calculation, you simply need to add a comma and the number four to the formula, rather than typing an extra LARGE function in its entirety:

=SUM(LARGE(T_Profits[Profit],{1,2,3,4}))

Naming Array Constants in Excel

If you find yourself repeatedly using the same set of static values in Excel, naming an array constant saves you from typing it manually each time.

To create a named array constant, in the Formulas tab on the ribbon, click “Name Manager.”

The Name Manager icon in the Formula tab on Excel's ribbon is selected.

Then, in the Name Manager dialog box, click “New.”

The New button is selected in Excel's Name Manager dialog box.

Next, in the Refers To field, type the equal sign, followed by an opening curly brace:

={
The equal sign and the opening curly brace is typed in the Refers To field of Excel's New Name dialog box.

Now, type the array constant, remembering that to create a horizontal (row) array, the values must be separated by commas, and for vertical (column) arrays, you need to separate them with semicolons. Also, remember that text values must be enclosed in double quotes. When you’re done, close the curly braces:

={"Mon","Tue","Wed","Thu","Fri","Sat","Sun"}
Shorthand days of the week are typed as an array constant into the Refers To field of Excel's New Name dialog box.

Finally, in the Name field, type a memorable name for your array constant, and click “OK.”

The word 'Days' is typed into Name field of Excel's New Name dialog box.

You can now use this array constant in your workbook by typing the equal sign followed by the name you just assigned and pressing Enter:

An array constant named 'Days' is inserted into an Excel spreadsheet, starting in cell B1 and spilling across to cell H1.

As with unnamed array constants, you can use them in formulas. In this example, the array constant named Fives is:

={5,10,15,20}

So, multiplying the value in cell A1 by this named array constant produces four separate results:

=A1*Fives
The value 100, typed into cell A1, is multipled by an array constant named 'Fives' to produce four separate results in cells B1 to E1.

Points to Note When Using Array Constants in Excel

Despite the many benefits of using array constants in Excel, there are some rules and limitations you should be aware of:

  • Dynamic array formulas cannot spill into structured table columns, so array constants that produce multi-cell results can only be used in regular cells. That said, array constants themselves can operate on data within tables.
  • Array constants can only contain text in double quotes, plain numbers (no currency symbols or percent signs), or Boolean values (TRUE and FALSE), separated by the comma and semicolon delimiters. They can’t contain cell references, other arrays, formulas, or wildcards.
  • Because you can’t reference cells in array constants, all values must be hard-coded (hence their name, array constants). As a result, formulas containing array constants are less flexible than those without.
  • If you plan to share your workbook with people less experienced in Excel, beware of the black-box effect that array constants create. That is to say, because the calculation process in array constants is less transparent than in standard formulas, those unfamiliar with array logic might struggle to understand how the spreadsheet works.
  • In some cases, using a dynamic array function is more efficient than using an array constant. For example, rather than inputting a constant such as {1,2,3}, you can use the SEQUENCE function to produce the same result.
  • Because the way array constants are handled in Excel changed dramatically when dynamic arrays were introduced, when an Excel file created in a modern version is opened in an older version, spilled arrays are converted into CSE formulas.

Array constants are particularly handy when used as arguments in Excel functions that don’t return dynamic arrays by default. However, dynamic array functions—available in one-off versions of Excel from 2021 onward, Excel for Microsoft 365, and Excel for the web—are designed specifically to return multiple values into a range of cells. Examples of these special functions include FILTER, SORT and SORTBY, UNIQUE, and XLOOKUP.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top