Array in excel with example

An array formula is a formula that can perform multiple calculations on one or more items in an array. You can think of an array as a row or column of values, or a combination of rows and columns of values. Array formulas can return either multiple results, or a single result.

Beginning with the September 2018 update for Microsoft 365, any formula that can return multiple results will automatically spill them either down, or across into neighboring cells. This change in behavior is also accompanied by several new dynamic array functions. Dynamic array formulas, whether they’re using existing functions or the dynamic array functions, only need to be input into a single cell, then confirmed by pressing Enter. Earlier, legacy array formulas require first selecting the entire output range, then confirming the formula with Ctrl+Shift+Enter. They’re commonly referred to as CSE formulas.

You can use array formulas to perform complex tasks, such as:

  • Quickly create sample datasets.

  • Count the number of characters contained in a range of cells.

  • Sum only numbers that meet certain conditions, such as the lowest values in a range, or numbers that fall between an upper and lower boundary.

  • Sum every Nth value in a range of values.

The following examples show you how to create multi-cell and single-cell array formulas. Where possible, we’ve included examples with some of the dynamic array functions, as well as existing array formulas entered as both dynamic and legacy arrays.

Download our examples

Download an example workbook with all the array formula examples in this article.

This exercise shows you how to use multi-cell and single-cell array formulas to calculate a set of sales figures. The first set of steps uses a multi-cell formula to calculate a set of subtotals. The second set uses a single-cell formula to calculate a grand total.

  • Multi-cell array formula

    Multi-cell array function in cell H10 =F10:F19*G10:G19 to calculate number of cars sold by unit price

  • Here we’re calculating Total Sales of coupes and sedans for each salesperson by entering =F10:F19*G10:G19 in cell H10.

    When you press Enter, you’ll see the results spill down to cells H10:H19. Notice that the spill range is highlighted with a border when you select any cell within the spill range. You might also notice that the formulas in cells H10:H19 are grayed out. They’re just there for reference, so if you want to adjust the formula, you’ll need to select cell H10, where the master formula lives.

  • Single-cell array formula

    Single-cell array formula to calculate a grand total with =SUM(F10:F19*G10:G19)

    In cell H20 of the example workbook, type or copy and paste =SUM(F10:F19*G10:G19), and then press Enter.

    In this case, Excel multiplies the values in the array (the cell range F10 through G19), and then uses the SUM function to add the totals together. The result is a grand total of $1,590,000 in sales.

    This example shows how powerful this type of formula can be. For example, suppose you have 1,000 rows of data. You can sum part or all of that data by creating an array formula in a single cell instead of dragging the formula down through the 1,000 rows. Also, notice that the single-cell formula in cell H20 is completely independent of the multi-cell formula (the formula in cells H10 through H19). This is another advantage of using array formulas — flexibility. You could change the other formulas in column H without affecting the formula in H20. It can also be good practice to have independent totals like this, as it helps validate the accuracy of your results.

  • Dynamic array formulas also offer these advantages:

    • Consistency    If you click any of the cells from H10 downward, you see the same formula. That consistency can help ensure greater accuracy.

    • Safety    You can’t overwrite a component of a multi-cell array formula. For example, click cell H11 and press Delete. Excel won’t change the array’s output. To change it, you need to select the top-left cell in the array, or cell H10.

    • Smaller file sizes    You can often use a single array formula instead of several intermediate formulas. For example, the car sales example uses one array formula to calculate the results in column E. If you had used standard formulas such as =F10*G10, F11*G11, F12*G12, etc., you would have used 11 different formulas to calculate the same results. That’s not a big deal, but what if you had thousands of rows to total? Then it can make a big difference.

    • Efficiency    Array functions can be an efficient way to build complex formulas. The array formula =SUM(F10:F19*G10:G19) is the same as this: =SUM(F10*G10,F11*G11,F12*G12,F13*G13,F14*G14,F15*G15,F16*G16,F17*G17,F18*G18,F19*G19).

    • Spilling    Dynamic array formulas will automatically spill into the output range. If your source data is in an Excel table, then your dynamic array formulas will automatically resize as you add or remove data.

    • #SPILL! error    Dynamic arrays introduced the #SPILL! error, which indicates that the intended spill range is blocked for some reason. When you resolve the blockage, the formula will automatically spill.

Array constants are a component of array formulas. You create array constants by entering a list of items and then manually surrounding the list with braces ({ }), like this:

={1,2,3,4,5} or ={«January»,»February»,»March»}

If you separate the items by using commas, you create a horizontal array (a row). If you separate the items by using semicolons, you create a vertical array (a column). To create a two-dimensional array, you delimit the items in each row with commas, and delimit each row with semicolons.

The following procedures will give you some practice in creating horizontal, vertical, and two-dimensional constants. We’ll show examples using the SEQUENCE function to automatically generate array constants, as well as manually entered array constants.

  • Create a horizontal constant

    Use the workbook from the previous examples, or create a new workbook. Select any empty cell and enter =SEQUENCE(1,5). The SEQUENCE function builds a 1 row by 5 column array the same as ={1,2,3,4,5}. The following result is displayed:

    Create a horizontal array constant with =SEQUENCE(1,5) or ={1,2,3,4,5}

  • Create a vertical constant

    Select any blank cell with room beneath it, and enter =SEQUENCE(5), or ={1;2;3;4;5}. The following result is displayed:

    Create a vertical array constant with =SEQUENCE(5), or ={1;2;3;4;5}

  • Create a two-dimensional constant

    Select any blank cell with room to the right and beneath it, and enter =SEQUENCE(3,4). You see the following result:

    Create a 3 row by 4 column array constant with =SEQUENCE(3,4)

    You can also enter: or ={1,2,3,4;5,6,7,8;9,10,11,12}, but you’ll want to pay attention to where you put semi-colons versus commas.

    As you can see, the SEQUENCE option offers significant advantages over manually entering your array constant values. Primarily, it saves you time, but it can also help reduce errors from manual entry. It’s also easier to read, especially as the semi-colons can be hard to distinguish from the comma separators.

Here’s an example that uses array constants as part of a bigger formula. In the sample workbook, go to the Constant in a formula worksheet, or create a new worksheet.

In cell D9, we entered =SEQUENCE(1,5,3,1), but you could also enter 3, 4, 5, 6, and 7 in cells A9:H9. There’s nothing special about that particular number selection, we just chose something other than 1-5 for differentiation.

In cell E11, enter =SUM(D9:H9*SEQUENCE(1,5)), or =SUM(D9:H9*{1,2,3,4,5}). The formulas return 85.

Use array constants in formulas. In this example, we used =SUM(D9:H(*SEQUENCE(1,5))

The SEQUENCE function builds the equivalent of the array constant {1,2,3,4,5}. Because Excel performs operations on expressions enclosed in parentheses first, the next two elements that come into play are the cell values in D9:H9, and the multiplication operator (*). At this point, the formula multiplies the values in the stored array by the corresponding values in the constant. It’s the equivalent of:

=SUM(D9*1,E9*2,F9*3,G9*4,H9*5), or =SUM(3*1,4*2,5*3,6*4,7*5)

Finally, the SUM function adds the values, and returns 85.

To avoid using the stored array and keep the operation entirely in memory, you can replace it with another array constant:

=SUM(SEQUENCE(1,5,3,1)*SEQUENCE(1,5)), or =SUM({3,4,5,6,7}*{1,2,3,4,5})

Elements that you can use in array constants

  • Array constants can contain numbers, text, logical values (such as TRUE and FALSE), and error values such as #N/A. You can use numbers in integer, decimal, and scientific formats. If you include text, you need to surround it with quotation marks («text”).

  • Array constants can’t contain additional arrays, formulas, or functions. In other words, they can contain only text or numbers that are separated by commas or semicolons. Excel displays a warning message when you enter a formula such as {1,2,A1:D4} or {1,2,SUM(Q2:Z8)}. Also, numeric values can’t contain percent signs, dollar signs, commas, or parentheses.

One of the best ways to use array constants is to name them. Named constants can be much easier to use, and they can hide some of the complexity of your array formulas from others. To name an array constant and use it in a formula, do the following:

Go to Formulas > Defined Names > Define Name. In the Name box, type Quarter1. In the Refers to box, enter the following constant (remember to type the braces manually):

={«January»,»February»,»March»}

The dialog box should now look like this:

Add a named array constant from Formulas > Defined Names > Name Manager > New

Click OK, then select any row with three blank cells, and enter =Quarter1.

The following result is displayed:

Use a named array constant in a formula, like =Quarter1, where Quarter1 has been defined as ={"January","February","March"}

If you want the results to spill vertically instead of horizontally, you can use =TRANSPOSE(Quarter1).

If you want to display a list of 12 months, like you might use when building a financial statement, you can base one off the current year with the SEQUENCE function. The neat thing about this function is that even though only the month is displaying, there is a valid date behind it that you can use in other calculations. You’ll find these examples on the Named array constant and Quick sample dataset worksheets in the example workbook.

=TEXT(DATE(YEAR(TODAY()),SEQUENCE(1,12),1),»mmm»)

Use a combination of the TEXT, DATE, YEAR, TODAY, and SEQUENCE functions to build a dynamic list of 12 months

This uses the DATE function to create a date based on the current year, SEQUENCE creates an array constant from 1 to 12 for January through December, then the TEXT function converts the display format to «mmm» (Jan, Feb, Mar, etc.). If you wanted to display the full month name, such as January, you’d use «mmmm».

When you use a named constant as an array formula, remember to enter the equal sign, as in =Quarter1, not just Quarter1. If you don’t, Excel interprets the array as a string of text and your formula won’t work as expected. Finally, keep in mind that you can use combinations of functions, text and numbers. It all depends on how creative you want to get.

The following examples demonstrate a few of the ways in which you can put array constants to use in array formulas. Some of the examples use the TRANSPOSE function to convert rows to columns and vice versa.

  • Multiple each item in an array

    Enter =SEQUENCE(1,12)*2, or ={1,2,3,4;5,6,7,8;9,10,11,12}*2

    You can also divide with (/), add with (+), and subtract with ().

  • Square the items in an array

    Enter =SEQUENCE(1,12)^2, or ={1,2,3,4;5,6,7,8;9,10,11,12}^2

  • Find the square root of squared items in an array

    Enter =SQRT(SEQUENCE(1,12)^2), or =SQRT({1,2,3,4;5,6,7,8;9,10,11,12}^2)

  • Transpose a one-dimensional row

    Enter =TRANSPOSE(SEQUENCE(1,5)), or =TRANSPOSE({1,2,3,4,5})

    Even though you entered a horizontal array constant, the TRANSPOSE function converts the array constant into a column.

  • Transpose a one-dimensional column

    Enter =TRANSPOSE(SEQUENCE(5,1)), or =TRANSPOSE({1;2;3;4;5})

    Even though you entered a vertical array constant, the TRANSPOSE function converts the constant into a row.

  • Transpose a two-dimensional constant

    Enter =TRANSPOSE(SEQUENCE(3,4)), or =TRANSPOSE({1,2,3,4;5,6,7,8;9,10,11,12})

    The TRANSPOSE function converts each row into a series of columns.

This section provides examples of basic array formulas.

  • Create an array from existing values

    The following example explains how to use array formulas to create a new array from an existing array.

    Enter =SEQUENCE(3,6,10,10), or ={10,20,30,40,50,60;70,80,90,100,110,120;130,140,150,160,170,180}

    Be sure to type { (opening brace) before you type 10, and } (closing brace) after you type 180, because you’re creating an array of numbers.

    Next, enter =D9#, or =D9:I11 in a blank cell. A 3 x 6 array of cells appears with the same values you see in D9:D11. The # sign is called the spilled range operator, and it’s Excel’s way of referencing the entire array range instead of having to type it out.

    Use the spilled range operator (#) to reference an existing array

  • Create an array constant from existing values

    You can take the results of a spilled array formula and convert that into its component parts. Select cell D9, then press F2 to switch to edit mode. Next, press F9 to convert the cell references to values, which Excel then converts into an array constant. When you press Enter, the formula, =D9#, should now be ={10,20,30;40,50,60;70,80,90}.

  • Count characters in a range of cells

    The following example shows you how to count the number of characters in a range of cells. This includes spaces.

    Count the total number of characters in a range, and other arrays for working with text strings

    =SUM(LEN(C9:C13))

    In this case, the LEN function returns the length of each text string in each of the cells in the range. The SUM function then adds those values together and displays the result (66). If you wanted to get average number of characters, you could use:

    =AVERAGE(LEN(C9:C13))

  • Contents of longest cell in range C9:C13

    =INDEX(C9:C13,MATCH(MAX(LEN(C9:C13)),LEN(C9:C13),0),1)

    This formula works only when a data range contains a single column of cells.

    Let’s take a closer look at the formula, starting from the inner elements and working outward. The LEN function returns the length of each of the items in the cell range D2:D6. The MAX function calculates the largest value among those items, which corresponds to the longest text string, which is in cell D3.

    Here’s where things get a little complex. The MATCH function calculates the offset (the relative position) of the cell that contains the longest text string. To do that, it requires three arguments: a lookup value, a lookup array, and a match type. The MATCH function searches the lookup array for the specified lookup value. In this case, the lookup value is the longest text string:

    MAX(LEN(C9:C13)

    and that string resides in this array:

    LEN(C9:C13)

    The match type argument in this case is 0. The match type can be a 1, 0, or -1 value.

    • 1 — returns the largest value that is less than or equal to the lookup val

    • 0 — returns the first value exactly equal to the lookup value

    • -1 — returns the smallest value that is greater than or equal to the specified lookup value

    • If you omit a match type, Excel assumes 1.

    Finally, the INDEX function takes these arguments: an array, and a row and column number within that array. The cell range C9:C13 provides the array, the MATCH function provides the cell address, and the final argument (1) specifies that the value comes from the first column in the array.

    If you wanted to get the contents of the smallest text string, you would replace MAX in the above example with MIN.

  • Find the n smallest values in a range

    This example shows how to find the three smallest values in a range of cells, where an array of sample data in cells B9:B18has been created with: =INT(RANDARRAY(10,1)*100). Note that RANDARRAY is a volatile function, so you’ll get a new set of random numbers each time Excel calculates.

    Excel array formula to find the Nth smallest value: =SMALL(B9#,SEQUENCE(D9))

    Enter =SMALL(B9#,SEQUENCE(D9), =SMALL(B9:B18,{1;2;3})

    This formula uses an array constant to evaluate the SMALL function three times and return the smallest 3 members in the array that’s contained in cells B9:B18, where 3 is a variable value in cell D9. To find more values, you can increase the value in the SEQUENCE function, or add more arguments to the constant. You can also use additional functions with this formula, such as SUM or AVERAGE. For example:

    =SUM(SMALL(B9#,SEQUENCE(D9))

    =AVERAGE(SMALL(B9#,SEQUENCE(D9))

  • Find the n largest values in a range

    To find the largest values in a range, you can replace the SMALL function with the LARGE function. In addition, the following example uses the ROW and INDIRECT functions.

    Enter =LARGE(B9#,ROW(INDIRECT(«1:3»))), or =LARGE(B9:B18,ROW(INDIRECT(«1:3»)))

    At this point, it may help to know a bit about the ROW and INDIRECT functions. You can use the ROW function to create an array of consecutive integers. For example, select an empty and enter:

    =ROW(1:10)

    The formula creates a column of 10 consecutive integers. To see a potential problem, insert a row above the range that contains the array formula (that is, above row 1). Excel adjusts the row references, and the formula now generates integers from 2 to 11. To fix that problem, you add the INDIRECT function to the formula:

    =ROW(INDIRECT(«1:10»))

    The INDIRECT function uses text strings as its arguments (which is why the range 1:10 is surrounded by quotation marks). Excel does not adjust text values when you insert rows or otherwise move the array formula. As a result, the ROW function always generates the array of integers that you want. You could just as easily use SEQUENCE:

    =SEQUENCE(10)

    Let’s examine the formula that you used earlier — =LARGE(B9#,ROW(INDIRECT(«1:3»))) — starting from the inner parentheses and working outward: The INDIRECT function returns a set of text values, in this case the values 1 through 3. The ROW function in turn generates a three-cell column array. The LARGE function uses the values in the cell range B9:B18, and it is evaluated three times, once for each reference returned by the ROW function. If you want to find more values, you add a greater cell range to the INDIRECT function. Finally, as with the SMALL examples, you can use this formula with other functions, such as SUM and AVERAGE.

  • Sum a range that contains error values

    The SUM function in Excel does not work when you try to sum a range that contains an error value, such as #VALUE! or #N/A. This example shows you how to sum the values in a range named Data that contains errors:

    Use arrays to deal with errors. For example, =SUM(IF(ISERROR(Data),"",Data) will sum the range named Data even if it includes errors, like #VALUE! or #NA!.

  • =SUM(IF(ISERROR(Data),»»,Data))

    The formula creates a new array that contains the original values minus any error values. Starting from the inner functions and working outward, the ISERROR function searches the cell range (Data) for errors. The IF function returns a specific value if a condition you specify evaluates to TRUE and another value if it evaluates to FALSE. In this case, it returns empty strings («») for all error values because they evaluate to TRUE, and it returns the remaining values from the range (Data) because they evaluate to FALSE, meaning that they don’t contain error values. The SUM function then calculates the total for the filtered array.

  • Count the number of error values in a range

    This example is like the previous formula, but it returns the number of error values in a range named Data instead of filtering them out:

    =SUM(IF(ISERROR(Data),1,0))

    This formula creates an array that contains the value 1 for the cells that contain errors and the value 0 for the cells that don’t contain errors. You can simplify the formula and achieve the same result by removing the third argument for the IF function, like this:

    =SUM(IF(ISERROR(Data),1))

    If you don’t specify the argument, the IF function returns FALSE if a cell does not contain an error value. You can simplify the formula even more:

    =SUM(IF(ISERROR(Data)*1))

    This version works because TRUE*1=1 and FALSE*1=0.

You might need to sum values based on conditions.

You can use arrays to calculate based on certain conditions. =SUM(IF(Sales>0,Sales)) will sum all values greater than 0 in a range called Sales.

For example, this array formula sums just the positive integers in a range named Sales, which represents cells E9:E24 in the example above:

=SUM(IF(Sales>0,Sales))

The IF function creates an array of positive and false values. The SUM function essentially ignores the false values because 0+0=0. The cell range that you use in this formula can consist of any number of rows and columns.

You can also sum values that meet more than one condition. For example, this array formula calculates values greater than 0 AND less than 2500:

=SUM((Sales>0)*(Sales<2500)*(Sales))

Keep in mind that this formula returns an error if the range contains one or more non-numeric cells.

You can also create array formulas that use a type of OR condition. For example, you can sum values that are greater than 0 OR less than 2500:

=SUM(IF((Sales>0)+(Sales<2500),Sales))

You can’t use the AND and OR functions in array formulas directly because those functions return a single result, either TRUE or FALSE, and array functions require arrays of results. You can work around the problem by using the logic shown in the previous formula. In other words, you perform math operations, such as addition or multiplication on values that meet the OR or AND condition.

This example shows you how to remove zeros from a range when you need to average the values in that range. The formula uses a data range named Sales:

=AVERAGE(IF(Sales<>0,Sales))

The IF function creates an array of values that do not equal 0 and then passes those values to the AVERAGE function.

This array formula compares the values in two ranges of cells named MyData and YourData and returns the number of differences between the two. If the contents of the two ranges are identical, the formula returns 0. To use this formula, the cell ranges need to be the same size and of the same dimension. For example, if MyData is a range of 3 rows by 5 columns, YourData must also be 3 rows by 5 columns:

=SUM(IF(MyData=YourData,0,1))

The formula creates a new array of the same size as the ranges that you are comparing. The IF function fills the array with the value 0 and the value 1 (0 for mismatches and 1 for identical cells). The SUM function then returns the sum of the values in the array.

You can simplify the formula like this:

=SUM(1*(MyData<>YourData))

Like the formula that counts error values in a range, this formula works because TRUE*1=1, and FALSE*1=0.

This array formula returns the row number of the maximum value in a single-column range named Data:

=MIN(IF(Data=MAX(Data),ROW(Data),»»))

The IF function creates a new array that corresponds to the range named Data. If a corresponding cell contains the maximum value in the range, the array contains the row number. Otherwise, the array contains an empty string («»). The MIN function uses the new array as its second argument and returns the smallest value, which corresponds to the row number of the maximum value in Data. If the range named Data contains identical maximum values, the formula returns the row of the first value.

If you want to return the actual cell address of a maximum value, use this formula:

=ADDRESS(MIN(IF(Data=MAX(Data),ROW(Data),»»)),COLUMN(Data))

You’ll find similar examples in the sample workbook on the Differences between datasets worksheet.

This exercise shows you how to use multi-cell and single-cell array formulas to calculate a set of sales figures. The first set of steps uses a multi-cell formula to calculate a set of subtotals. The second set uses a single-cell formula to calculate a grand total.

  • Multi-cell array formula

Copy the entire table below and paste it into cell A1 in a blank worksheet.

Sales 
Person

Car 
Type

Number 
Sold

Unit 
Price

Total 
Sales

Barnhill

Sedan

5

33000

Coupe

4

37000

Ingle

Sedan

6

24000

Coupe

8

21000

Jordan

Sedan

3

29000

Coupe

1

31000

Pica

Sedan

9

24000

Coupe

5

37000

Sanchez

Sedan

6

33000

Coupe

8

31000

Formula (Grand Total)

Grand Total

‘=SUM(C2:C11*D2:D11)

=SUM(C2:C11*D2:D11)

  1. To see Total Sales of coupes and sedans for each salesperson, select cells E2:E11, enter the formula =C2:C11*D2:D11, and then press Ctrl+Shift+Enter.

  2. To see the Grand Total of all sales, select cell F11, enter the formula =SUM(C2:C11*D2:D11), and then press Ctrl+Shift+Enter.

When you press Ctrl+Shift+Enter, Excel surrounds the formula with braces ({ }) and inserts an instance of the formula in each cell of the selected range. This happens very quickly, so what you see in column E is the total sales amount for each car type for each salesperson. If you select E2, then select E3, E4, and so on, you’ll see that the same formula is shown: {=C2:C11*D2:D11}

The totals in column E are calculated by an array formula

  • Create a single-cell array formula

In cell D13 of the workbook, type the following formula, and then press Ctrl+Shift+Enter:


=SUM(C2:C11*D2:D11)

In this case, Excel multiplies the values in the array (the cell range C2 through D11) and then uses the SUM function to add the totals together. The result is a grand total of $1,590,000 in sales. This example shows how powerful this type of formula can be. For example, suppose you have 1,000 rows of data. You can sum part or all of that data by creating an array formula in a single cell instead of dragging the formula down through the 1,000 rows.

Also, notice that the single-cell formula in cell D13 is completely independent of the multi-cell formula (the formula in cells E2 through E11). This is another advantage of using array formulas — flexibility. You could change the formulas in column E or delete that column altogether, without affecting the formula in D13.

Array formulas also offer these advantages:

  • Consistency    If you click any of the cells from E2 downward, you see the same formula. That consistency can help ensure greater accuracy.

  • Safety    You cannot overwrite a component of a multi-cell array formula. For example, click cell E3 and press Delete. You have to either select the entire range of cells (E2 through E11) and change the formula for the entire array, or leave the array as is. As an added safety measure, you have to press Ctrl+Shift+Enter to confirm any change to the formula.

  • Smaller file sizes    You can often use a single array formula instead of several intermediate formulas. For example, the workbook uses one array formula to calculate the results in column E. If you had used standard formulas (such as =C2*D2, C3*D3, C4*D4…), you would have used 11 different formulas to calculate the same results.

In general, array formulas use standard formula syntax. They all begin with an equal (=) sign, and you can use most of the built-in Excel functions in your array formulas. The key difference is that when using an array formula, you press Ctrl+Shift+Enter to enter your formula. When you do this, Excel surrounds your array formula with braces — if you type the braces manually, your formula will be converted to a text string, and it won’t work.

Array functions can be an efficient way to build complex formulas. The array formula =SUM(C2:C11*D2:D11) is the same as this: =SUM(C2*D2,C3*D3,C4*D4,C5*D5,C6*D6,C7*D7,C8*D8,C9*D9,C10*D10,C11*D11).

Important: Press Ctrl+Shift+Enter whenever you need to enter an array formula. This applies to both single-cell and multi-cell formulas.

Whenever you work with multi-cell formulas, also remember:

  • Select the range of cells to hold your results before you enter the formula. You did this when you created the multi-cell array formula when you selected cells E2 through E11.

  • You can’t change the contents of an individual cell in an array formula. To try this, select cell E3 in the workbook and press Delete. Excel displays a message that tells you that you can’t change part of an array.

  • You can move or delete an entire array formula, but you can’t move or delete part of it. In other words, to shrink an array formula, you first delete the existing formula and then start over.

  • To delete an array formula, select the entire formula range (for example, E2:E11), then press Delete.

  • You can’t insert blank cells into, or delete cells from a multi-cell array formula.

At times, you may need to expand an array formula. Select the first cell in existing array range, and continue until you’ve selected the entire range that you want to extend the formula to. Press F2 to edit the formula,  then press CTRL+SHIFT+ENTER to confirm the formula once you’ve adjusted the formula range. The key is to select the entire range, starting with the top-left cell in the array. The top-left cell is the one that gets edited.

Array formulas are great, but they can have some disadvantages:

  • You may occasionally forget to press Ctrl+Shift+Enter. It can happen to even the most experienced Excel users. Remember to press this key combination whenever you enter or edit an array formula.

  • Other users of your workbook might not understand your formulas. In practice, array formulas are generally not explained in a worksheet. Therefore, if other people need to modify your workbooks, you should either avoid array formulas or make sure those people know about any array formulas and understand how to change them, if they need to.

  • Depending on the processing speed and memory of your computer, large array formulas can slow down calculations.

Array constants are a component of array formulas. You create array constants by entering a list of items and then manually surrounding the list with braces ({ }), like this:

={1,2,3,4,5}

By now, you know you need to press Ctrl+Shift+Enter when you create array formulas. Because array constants are a component of array formulas, you surround the constants with braces by manually typing them. You then use Ctrl+Shift+Enter to enter the entire formula.

If you separate the items by using commas, you create a horizontal array (a row). If you separate the items by using semicolons, you create a vertical array (a column). To create a two-dimensional array, you delimit the items in each row by using commas and delimit each row by using semicolons.

Here’s an array in a single row: {1,2,3,4}. Here’s an array in a single column: {1;2;3;4}. And here’s an array of two rows and four columns: {1,2,3,4;5,6,7,8}. In the two row array, the first row is 1, 2, 3, and 4, and the second row is 5, 6, 7, and 8. A single semicolon separates the two rows, between 4 and 5.

As with array formulas, you can use array constants with most of the built-in functions that Excel provides. The following sections explain how to create each kind of constant and how to use these constants with functions in Excel.

The following procedures will give you some practice in creating horizontal, vertical, and two-dimensional constants.

Create a horizontal constant

  1. In a blank worksheet, select cells A1 through E1.

  2. In the formula bar, enter the following formula, and then press Ctrl+Shift+Enter:


    ={1,2,3,4,5}

    In this case, you should type the opening and closing braces ({ }), and Excel will add the second set for you.

    The following result is displayed.

    Horizontal array constant in formula

Create a vertical constant

  1. In your workbook, select a column of five cells.

  2. In the formula bar, enter the following formula, and then press Ctrl+Shift+Enter:


    ={1;2;3;4;5}

    The following result is displayed.

    Vertical array constant in array formula

Create a two-dimensional constant

  1. In your workbook, select a block of cells four columns wide by three rows high.

  2. In the formula bar, enter the following formula, and then press Ctrl+Shift+Enter:


    ={1,2,3,4;5,6,7,8;9,10,11,12}

    You see the following result:

    Two-dimensional array constant in array formula

Use constants in formulas

Here is a simple example that uses constants:

  1. In the sample workbook, create a new worksheet.

  2. In cell A1, type 3, and then type 4 in B1, 5 in C1, 6 in D1, and 7 in E1.

  3. In cell A3, type the following formula, and then press Ctrl+Shift+Enter:


    =SUM(A1:E1*{1,2,3,4,5})

    Notice that Excel surrounds the constant with another set of braces, because you entered it as an array formula.

    Array formula with array constant

    The value 85 appears in cell A3.

The next section explains how the formula works.

The formula you just used contains several parts.

Syntax of array formula with array constant

1. Function

2. Stored array

3. Operator

4. Array constant

The last element inside the parentheses is the array constant: {1,2,3,4,5}. Remember that Excel does not surround array constants with braces; you actually type them. Also remember that after you add a constant to an array formula, you press Ctrl+Shift+Enter to enter the formula.

Because Excel performs operations on expressions enclosed in parentheses first, the next two elements that come into play are the values stored in the workbook (A1:E1) and the operator. At this point, the formula multiplies the values in the stored array by the corresponding values in the constant. It’s the equivalent of:

=SUM(A1*1,B1*2,C1*3,D1*4,E1*5)

Finally, the SUM function adds the values, and the sum 85 appears in cell A3.

To avoid using the stored array and to just keep the operation entirely in memory, replace the stored array with another array constant:

=SUM({3,4,5,6,7}*{1,2,3,4,5})

To try this, copy the function, select a blank cell in your workbook, paste the formula into the formula bar, and then press Ctrl+Shift+Enter. You’ll see the same result as you did in the earlier exercise that used the array formula:

=SUM(A1:E1*{1,2,3,4,5})

Array constants can contain numbers, text, logical values (such as TRUE and FALSE), and error values ( such as #N/A). You can use numbers in the integer, decimal, and scientific formats. If you include text, you need to surround the text with quotation marks («).

Array constants can’t contain additional arrays, formulas, or functions. In other words, they can contain only text or numbers that are separated by commas or semicolons. Excel displays a warning message when you enter a formula such as {1,2,A1:D4} or {1,2,SUM(Q2:Z8)}. Also, numeric values can’t contain percent signs, dollar signs, commas, or parentheses.

One of the best way to use array constants is to name them. Named constants can be much easier to use, and they can hide some of the complexity of your array formulas from others. To name an array constant and use it in a formula, do the following:

  1. On the Formulas tab, in the Defined Names group, click Define Name.
    The Define Name dialog box appears.

  2. In the Name box, type Quarter1.

  3. In the Refers to box, enter the following constant (remember to type the braces manually):


    ={«January»,»February»,»March»}

    The contents of the dialog box now looks like this:

    Edit Name dialog box with formula

  4. Click OK, and then select a row of three blank cells.

  5. Type the following formula, and then press Ctrl+Shift+Enter.


    =Quarter1

    The following result is displayed.

    Named array entered as formula

When you use a named constant as an array formula, remember to enter the equal sign. If you don’t, Excel interprets the array as a string of text and your formula won’t work as expected. Finally, keep in mind that you can use combinations of text and numbers.

Look for the following problems when your array constants don’t work:

  • Some elements might not be separated with the proper character. If you omit a comma or semicolon, or if you put one in the wrong place, the array constant might not be created correctly, or you might see a warning message.

  • You might have selected a range of cells that doesn’t match the number of elements in your constant. For example, if you select a column of six cells for use with a five-cell constant, the #N/A error value appears in the empty cell. Conversely, if you select too few cells, Excel omits the values that don’t have a corresponding cell.

The following examples demonstrate a few of the ways in which you can put array constants to use in array formulas. Some of the examples use the TRANSPOSE function to convert rows to columns and vice versa.

Multiply each item in an array

  1. Create a new worksheet, and then select a block of empty cells four columns wide by three rows high.

  2. Type the following formula, and then press Ctrl+Shift+Enter:


    ={1,2,3,4;5,6,7,8;9,10,11,12}*2

Square the items in an array

  1. Select a block of empty cells four columns wide by three rows high.

  2. Type the following array formula, and then press Ctrl+Shift+Enter:


    ={1,2,3,4;5,6,7,8;9,10,11,12}*{1,2,3,4;5,6,7,8;9,10,11,12}

    Alternatively, enter this array formula, which uses the caret operator (^):


    ={1,2,3,4;5,6,7,8;9,10,11,12}^2

Transpose a one-dimensional row

  1. Select a column of five blank cells.

  2. Type the following formula, and then press Ctrl+Shift+Enter:


    =TRANSPOSE({1,2,3,4,5})

    Even though you entered a horizontal array constant, the TRANSPOSE function converts the array constant into a column.

Transpose a one-dimensional column

  1. Select a row of five blank cells.

  2. Enter the following formula, and then press Ctrl+Shift+Enter:


    =TRANSPOSE({1;2;3;4;5})

Even though you entered a vertical array constant, the TRANSPOSE function converts the constant into a row.

Transpose a two-dimensional constant

  1. Select a block of cells three columns wide by four rows high.

  2. Enter the following constant, and then press Ctrl+Shift+Enter:


    =TRANSPOSE({1,2,3,4;5,6,7,8;9,10,11,12})

    The TRANSPOSE function converts each row into a series of columns.

This section provides examples of basic array formulas.

Create arrays and array constants from existing values

The following example explains how to use array formulas to create links between ranges of cells in different worksheets. It also shows you how to create an array constant from the same set of values.

Create an array from existing values

  1. On a worksheet in Excel, select cells C8:E10, and enter this formula:


    ={10,20,30;40,50,60;70,80,90}

    Be sure to type { (opening brace) before you type 10, and } (closing brace) after you type 90, because you’re creating an array of numbers.

  2. Press Ctrl+Shift+Enter, which enters this array of numbers in the cell range C8:E10 by using an array formula. On your worksheet, C8 through E10 should look like this:

    10

    20

    30

    40

    50

    60

    70

    80

    90

  3. Select the cell range C1 through E3.

  4. Enter the following formula in the formula bar, and then press Ctrl+Shift+Enter:


    =C8:E10

    A 3×3 array of cells appears in cells C1 through E3 with the same values you see in C8 through E10.

Create an array constant from existing values

  1. With cells C1:C3 selected, press F2 to switch to edit mode. 

  2. Press F9 to convert the cell references to values. Excel converts the values into an array constant. The formula should now be ={10,20,30;40,50,60;70,80,90}.

  3. Press Ctrl+Shift+Enter to enter the array constant as an array formula.

Count characters in a range of cells

The following example shows you how to count the number of characters, including spaces, in a range of cells.

  1. Copy this entire table and paste into a worksheet in cell A1.

    Data

    This is a

    bunch of cells that

    come together

    to form a

    single sentence.

    Total characters in A2:A6

    =SUM(LEN(A2:A6))

    Contents of longest cell (A3)

    =INDEX(A2:A6,MATCH(MAX(LEN(A2:A6)),LEN(A2:A6),0),1)

  2. Select cell A8, and then press Ctrl+Shift+Enter to see the total number of characters in cells A2:A6 (66).

  3. Select cell A10, and then press Ctrl+Shift+Enter to see the contents of the longest of cells A2:A6 (cell A3).

The following formula is used in cell A8 counts the total number of characters (66) in cells A2 through A6.


=SUM(LEN(A2:A6))

In this case, the LEN function returns the length of each text string in each of the cells in the range. The SUM function then adds those values together and displays the result (66).

Find the n smallest values in a range

This example shows how to find the three smallest values in a range of cells.

  1. Enter some random numbers in cells A1:A11.

  2. Select cells C1 through C3. This set of cells will hold the results returned by the array formula.

  3. Enter the following formula, and then press Ctrl+Shift+Enter:


    =SMALL(A1:A11,{1;2;3})

This formula uses an array constant to evaluate the SMALL function three times and return the smallest (1), second smallest (2), and third smallest (3) members in the array that is contained in cells A1:A10 To find more values, you add more arguments to the constant. You can also use additional functions with this formula, such as SUM or AVERAGE. For example:

=SUM(SMALL(A1:A10,{1,2,3})

=AVERAGE(SMALL(A1:A10,{1,2,3})

Find the n largest values in a range

To find the largest values in a range, you can replace the SMALL function with the LARGE function. In addition, the following example uses the ROW and INDIRECT functions.

  1. Select cells D1 through D3.

  2. In the formula bar, enter this formula, and then press Ctrl+Shift+Enter:


    =LARGE(A1:A10,ROW(INDIRECT(«1:3»)))

At this point, it may help to know a bit about the ROW and INDIRECT functions. You can use the ROW function to create an array of consecutive integers. For example, select an empty column of 10 cells in your practice workbook, enter this array formula, and then press Ctrl+Shift+Enter:


=ROW(1:10)

The formula creates a column of 10 consecutive integers. To see a potential problem, insert a row above the range that contains the array formula (that is, above row 1). Excel adjusts the row references, and the formula generates integers from 2 to 11. To fix that problem, you add the INDIRECT function to the formula:

=ROW(INDIRECT(«1:10»))

The INDIRECT function uses text strings as its arguments (which is why the range 1:10 is surrounded by double quotation marks). Excel does not adjust text values when you insert rows or otherwise move the array formula. As a result, the ROW function always generates the array of integers that you want.

Let’s take a look at the formula that you used earlier — =LARGE(A5:A14,ROW(INDIRECT(«1:3»))) — starting from the inner parentheses and working outward: The INDIRECT function returns a set of text values, in this case the values 1 through 3. The ROW function in turn generates a three-cell columnar array. The LARGE function uses the values in the cell range A5:A14, and it is evaluated three times, once for each reference returned by the ROW function. The values 3200, 2700, and 2000 are returned to the three-cell columnar array. If you want to find more values, you add a greater cell range to the INDIRECT function.

As with earlier examples, you can use this formula with other functions, such as SUM and AVERAGE.

Find the longest text string in a range of cells

Go back to the earlier text string example, enter the following formula in an empty cell, and press Ctrl+Shift+Enter:


=INDEX(A2:A6,MATCH(MAX(LEN(A2:A6)),LEN(A2:A6),0),1)

The text «bunch of cells that» appears.

Let’s take a closer look at the formula, starting from the inner elements and working outward. The LEN function returns the length of each of the items in the cell range A2:A6. The MAX function calculates the largest value among those items, which corresponds to the longest text string, which is in cell A3.

Here’s where things get a little complex. The MATCH function calculates the offset (the relative position) of the cell that contains the longest text string. To do that, it requires three arguments: a lookup value, a lookup array, and a match type. The MATCH function searches the lookup array for the specified lookup value. In this case, the lookup value is the longest text string:

(MAX(LEN(A2:A6))

and that string resides in this array:

LEN(A2:A6)

The match type argument is 0. The match type can consist of a 1, 0, or -1 value. If you specify 1, MATCH returns the largest value that is less than or equal to the lookup value. If you specify 0, MATCH returns the first value exactly equal to the lookup value. If you specify -1, MATCH finds the smallest value that is greater than or equal to the specified lookup value. If you omit a match type, Excel assumes 1.

Finally, the INDEX function takes these arguments: an array, and a row and column number within that array. The cell range A2:A6 provides the array, the MATCH function provides the cell address, and the final argument (1) specifies that the value comes from the first column in the array.

This section provides examples of advanced array formulas.

Sum a range that contains error values

The SUM function in Excel does not work when you try to sum a range that contains an error value, such as #N/A. This example shows you how to sum the values in a range named Data that contains errors.

=SUM(IF(ISERROR(Data),»»,Data))

The formula creates a new array that contains the original values minus any error values. Starting from the inner functions and working outward, the ISERROR function searches the cell range (Data) for errors. The IF function returns a specific value if a condition you specify evaluates to TRUE and another value if it evaluates to FALSE. In this case, it returns empty strings («») for all error values because they evaluate to TRUE, and it returns the remaining values from the range (Data) because they evaluate to FALSE, meaning that they don’t contain error values. The SUM function then calculates the total for the filtered array.

Count the number of error values in a range

This example is similar to the previous formula, but it returns the number of error values in a range named Data instead of filtering them out:

=SUM(IF(ISERROR(Data),1,0))

This formula creates an array that contains the value 1 for the cells that contain errors and the value 0 for the cells that don’t contain errors. You can simplify the formula and achieve the same result by removing the third argument for the IF function, like this:

=SUM(IF(ISERROR(Data),1))

If you don’t specify the argument, the IF function returns FALSE if a cell does not contain an error value. You can simplify the formula even more:

=SUM(IF(ISERROR(Data)*1))

This version works because TRUE*1=1 and FALSE*1=0.

Sum values based on conditions

You might need to sum values based on conditions. For example, this array formula sums just the positive integers in a range named Sales:

=SUM(IF(Sales>0,Sales))

The IF function creates an array of positive values and false values. The SUM function essentially ignores the false values because 0+0=0. The cell range that you use in this formula can consist of any number of rows and columns.

You can also sum values that meet more than one condition. For example, this array formula calculates values greater than 0 and less than or equal to 5:

=SUM((Sales>0)*(Sales<=5)*(Sales))

Keep in mind that this formula returns an error if the range contains one or more non-numeric cells.

You can also create array formulas that use a type of OR condition. For example, you can sum values that are less than 5 and greater than 15:

=SUM(IF((Sales<5)+(Sales>15),Sales))

The IF function finds all values smaller than 5 and greater than 15 and then passes those values to the SUM function.

You can’t use the AND and OR functions in array formulas directly because those functions return a single result, either TRUE or FALSE, and array functions require arrays of results. You can work around the problem by using the logic shown in the previous formula. In other words, you perform math operations, such as addition or multiplication, on values that meet the OR or AND condition.

Compute an average that excludes zeros

This example shows you how to remove zeros from a range when you need to average the values in that range. The formula uses a data range named Sales:

=AVERAGE(IF(Sales<>0,Sales))

The IF function creates an array of values that do not equal 0 and then passes those values to the AVERAGE function.

Count the number of differences between two ranges of cells

This array formula compares the values in two ranges of cells named MyData and YourData and returns the number of differences between the two. If the contents of the two ranges are identical, the formula returns 0. To use this formula, the cell ranges need to be the same size and of the same dimension (for example, if MyData is a range of 3 rows by 5 columns, YourData must also be 3 rows by 5 columns):

=SUM(IF(MyData=YourData,0,1))

The formula creates a new array of the same size as the ranges that you are comparing. The IF function fills the array with the value 0 and the value 1 (0 for mismatches and 1 for identical cells). The SUM function then returns the sum of the values in the array.

You can simplify the formula like this:

=SUM(1*(MyData<>YourData))

Like the formula that counts error values in a range, this formula works because TRUE*1=1, and FALSE*1=0.

Find the location of the maximum value in a range

This array formula returns the row number of the maximum value in a single-column range named Data:

=MIN(IF(Data=MAX(Data),ROW(Data),»»))

The IF function creates a new array that corresponds to the range named Data. If a corresponding cell contains the maximum value in the range, the array contains the row number. Otherwise, the array contains an empty string («»). The MIN function uses the new array as its second argument and returns the smallest value, which corresponds to the row number of the maximum value in Data. If the range named Data contains identical maximum values, the formula returns the row of the first value.

If you want to return the actual cell address of a maximum value, use this formula:

=ADDRESS(MIN(IF(Data=MAX(Data),ROW(Data),»»)),COLUMN(Data))

Acknowledgement

Parts of this article were based on a series of Excel Power User columns written by Colin Wilcox, and adapted from chapters 14 and 15 of Excel 2002 Formulas, a book written by John Walkenbach, a former Excel MVP.

Need more help?

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

See Also

Dynamic arrays and spilled array behavior

Dynamic array formulas vs. legacy CSE array formulas

FILTER function

RANDARRAY function

SEQUENCE function

SORT function

SORTBY function

UNIQUE function

#SPILL! errors in Excel

Implicit intersection operator: @

Overview of formulas

Excel Array Formula Examples

In Excel, an Array Formula allows you to do powerful calculations on one or more value sets. The result may fit in a single cell or it may be an array. An array is just a list or range of values, but an Array Formula is a special type of formula that must be entered by pressing Ctrl+Shift+Enter. The formula bar will show the formula surrounded by curly brackets {=…}.

Array formulas are frequently used for data analysis, conditional sums and lookups, linear algebra, matrix math and manipulation, and much more. A new Excel user might come across array formulas in other people’s spreadsheets, but creating array formulas is typically an intermediate-to-advanced topic.

Download the Example File (ArrayFormulas.xlsx)

Topics and Examples in This Article:

  • Entering an Array Formula
  • Using Array Constants
  • A Simple Array Formula Example
  • Entering a Multi-Cell Array Formula
  • Nested IF Array Formulas
  • COUNTIF Alternative: SUM-Boolean Array Formulas
  • Multi-Criteria Boolean Array Formulas
  • Sequential Number Arrays (1,2,3,…)
  • Formulas for Matrices: MUNIT, MMULT, TRANSPOSE, etc.
  • Other Array Formula Examples

Watch the Intro Video

Entering and Identifying an Array Formula

  1. When using an Array Formula, you press Ctrl+Shift+Enter instead of just Enter after entering or editing the formula. This is why array formulas are often called CSE formulas.
  2. An Array Formula will show curly brackets or braces around the formula in the Formula Bar like this: {=SUM(A1:A5*B1:B5)}
  3. Array Constants (arrays «hard-coded» into formulas) are enclosed in braces { } and use commas to separate columns, and semi-colons to separate rows, like this 2×3 array: {1, 1, 1; 2, 2, 2}
  4. If an Array Formula returns more than one value (a multi-cell array formula), first select a range of cells equal to size of the returned array, then enter your formula.
  5. To select all the cells within a multi-cell array: Press F5 > Special > Current Array.

! Every time you edit an Array Formula, you must remember to press Ctrl+Shift+Enter afterward. If you forget to, the formula may return an error without you realizing it.

NOTE Google Sheets uses the ARRAYFORMULA function instead of showing the formula surrounded by braces. It is not necessary to press Ctrl+Shift+Enter in Google Sheets, but if you do, ARRAYFORMULA( is added to the beginning of the formula.

Using Array Constants in Formulas

Many functions allow you use array constants like {1,2,6,12} as arguments within formulas. An example that I often use in my yearly calendar templates returns the weekday abbreviation for a given date. The nice thing about this formula is that you can choose whether to display a single character or two characters.

=INDEX({"Su";"M";"Tu";"W";"Th";"F";"Sa"},WEEKDAY(theDate,1))

This formula is not technically an Array Formula because you don’t enter it using Ctrl+Shift+Enter. Using a hard-coded array within a formula does not necessarily require using Ctrl+Shift+Enter.

TIP If you are going to use the array constant in multiple formulas, you may want to first create a Named Constant. Go to Formulas > Name Manager > New Name, enter a descriptive name like payment_frequency and enter ={1,2,6,12} into the Refers To field. You can use the name within your formulas. If you ever want to change the values within that array constant, you only need to change it one place (within the Name Manager).

A Simple Array Formula Example

To start out, I will show how an array formula works using a very basic example. Let’s say that I have a list of tasks, the number of days each of those tasks will take, and a column for the percent complete. I want to know the total number of days that have been completed.

Without an array formula, you would create another column called «Completed» and multiply the number of days by the % complete, and copy the formula down. Then I would use SUM to total the number of days completed, like the image below:

Array Formula Example - How it Works

With an array formula, you can do essentially the same thing without having to create the extra column. Within a single cell, you can calculate the total days completed as =SUM(D18:D22*E18:E22), remembering to press Ctrl+Shift+Enter because it is an array formula.

{ =SUM(D18:D22*E18:E22) }

Evaluation Steps
Step 1: =SUM( {10;5;8;3;12} * {0.5;0.2;0.07;0.5;0.09} )
Step 2: =SUM( {10*0.5;5*0.2;8*0.7;3*0.5;12*0.09} )
Step 3: =SUM( {5;1;0.56;1.5;1.08} )
Step 4: =9.14

In this and other examples, I’ve shown the evaluation steps below the formula so that you can see how the formula works. You don’t actually type the curly brackets { }, but in this article I will surround all array formulas with brackets to indicate that they are entered as CSE formulas.

In the evaluation steps shown in the above example, you’ll see that Excel is multiplying each element of the first array by the corresponding element in the second array, and then SUM adds the results.

NOTE It turns out that this particular example can be used to show how the SUMPRODUCT function works, but the SUMPRODUCT function deserves its own article.

To take this example just a bit further, if all we wanted to know was the Total Percent Complete for the entire project, we can divide the total days completed (9.14) by the total days (38) all within a single array formula, and we don’t need column F at all (as shown in the image below).

Array Formula Example - Sum Product

This example is an example of a single-cell array formula, meaning that the formula is entered into a single cell.

Entering a Multi-Cell Array Formula

Whenever your array formula returns more than one value, if you want to display more than just the first value, you need to select the range of cells that will contain the resulting array before entering your formula. Doing this will result in a multi-cell array formula, meaning that the result of the formula is a multi-cell array.

Using the same example as above, we could use an array formula in the Completed column to calculate Days * Percent Complete. First, select cells F18:F22, then press = and enter the formula, followed by Ctrl+Shift+Enter (CSE). The image below is what it will look like just before you press CSE.

Array Multi-Cell Array Formula Example

You can edit a multi-cell array formula by selecting any of the cells in the array and then updating the formula and pressing Ctrl+Shift+Enter when you are done. However, you can’t use this technique to modify the size of the array.

«You can’t change part of an array» — This is the warning or error you will get if you try to insert rows or columns or change individual cells within a multi-cell array.

Using multi-cell array formulas can make it more difficult to customize a spreadsheet because to change the size of the array requires that you (1) delete the formula (after selecting all the cells of the array), (2) select the new range of cells, and (3) re-enter the array formula. TIP: Make sure to copy your original formula before deleting it. Then, when you re-enter the formula, you can paste it and modify the ranges.

Nested IF Array Formulas

A nested IF array formula can be very powerful and is probably one of the more common uses for array formulas in Excel. Although Excel provides the SUMIF and COUNTIF and AVERAGEIF functions, they don’t allow as much freedom as a nested IF array formula.

MAX-IF Array Formula

Older versions of Excel do not have the MAXIFS or MINIFS functions, so let’s create our own MAX-IF formula. When we use hyphens to name a formula, it usually means that we’re nesting the functions (IF within MAX in this case).

Let’s say that I have the following contact and sales log and I want a formula that will tell me when I last contacted Bob (cell H51).

MAX-IF Array Formula Example

Using MAX on the date range will give me that latest date (9/10/2017), but I only want to include the rows where the contact is Bob. So, I’ll use the MAX-IF array formula:

{ =MAX(IF(contact_range="Bob",date_range)) }

Evaluation Steps
Step 1: =MAX(IF({"Jim";"Bob";"Jim";"Bob";"Jim"}="Bob", date_range ))
Step 2: =MAX(IF({FALSE;TRUE;FALSE;TRUE;FALSE}, date_range ))
Step 3: =MAX( {FALSE,2/25/2017,FALSE,8/5/2017,FALSE} )
Step 4: =8/5/2017

LARGE-IF Array Formula

The LARGE and SMALL functions come in handy when you want to find the value that is perhaps the 2nd largest or 2nd smallest.

The following function will return the second largest sale where the contact is Jim.

{ =LARGE(IF(contact_range="Jim",sale_range),2) }

SMALL-IF Array Formula

This function returns the second smallest sale where the contact is Jim.

{ =SMALL(IF(contact_range="Jim",date_range),2) }

The LARGE and SMALL functions can be used for sorting arrays. More on that later. Hopefully, Excel will introduce a SORT function soon (Google Sheets has already done that).

The SMALL-IF formula can be used in combination with INDEX to do a lookup a value based on the Nth Match.

SUM-IF Array Formula

Yes, there is already a SUMIF function that is generally better than using an array formula, but we’ll be getting into more advanced SUM-IF array formulas, so it’s useful to see the simple example:

{ =SUM(IF(contact_range="Jim",sales_range)) }

More Reading: Chip Pearson provides some great examples of ways to use nested IF functions within the SUM and AVERAGE functions to ignore errors and zero values. See Chip Pearson’s article.

COUNTIF Alternative: SUM-Boolean Array Formulas

Although there is already a COUNTIF function, the criteria available in the COUNTIF family of functions is limited. An alternative method is to do a SUM of boolean (TRUE/FALSE) results that have been converted to 0s and 1s (FALSE=0, TRUE=1). Boolean results can be converted to 0s and 1s by adding +0, multiplying by *1 and by using double negation.

SUM-ISERROR: Count the number of Error values in a range

{ =SUM(1*ISERROR(range)) }
{ =SUM(0+ISERROR(range)) }
{ =SUM(--ISERROR(range)) }

Evaluation Steps
Step 1: =SUM( 1*{FALSE,TRUE,TRUE,FALSE,TRUE} )
Step 2: =SUM( {0,1,1,0,1} )
Step 3: =3

SUM-ISBLANK: Count the number of Blank values in a range

{ =SUM(--ISBLANK(range)) }

Remember: A formula that returns an empty «» string is considered NOT blank.

SUM-NOT-ISBLANK: Count the number of Non-Blank values in a range

{ =SUM(--NOT(ISBLANK(range)) }

Multi-Criteria Boolean Array Formulas

The AND and OR functions return only a single value, even when they contain multiple arrays, so we don’t generally use them within array formulas.

For multiple-criteria logical array formulas, such as SUM-IF between two dates, you need to do the boolean logic by adding boolean values for «or» conditions and by multiplying boolean values for «and» conditions.

SUM-IF Between Two Dates

Yes, SUMIFS would be easier, but let’s assume we are using an older version of Excel. Referring back to the Contact and Sales log, we’ll sum all of the Sales between 2/1/2017 and 9/1/2017, meaning that Date >= 2/1/2017 AND Date <= 9/1/2017.

{ =SUM(IF((date_range>=start)*(date_range<=end), sum_range) ) }

Evaluation Steps
Step 1: SUM(IF({FALSE,TRUE,TRUE,TRUE,TRUE}*{TRUE,TRUE,TRUE,TRUE,FALSE},sum_range))
Step 2: SUM(IF({0,1,1,1,0},sum_range))
Step 3: SUM({FALSE,300,500,0,FALSE})
Step 4: 800

In this case we don’t need to use 1*(…) to convert the boolean values, because the boolean values are converted to 0s and 1s automatially when we multiply the two arrays together. The IF function in Excel treats the value 0 as FALSE and all other values as TRUE.

Overlapping OR Conditions

To demonstrate a logical OR condition, we’ll sum the sales where Name = «Bob» OR Date > 7/1/2017. An «or» condition is true when one or more of the conditions is true, so we check whether the sum of the expressions is greater than 0.

{ =SUM(IF( ((contact_range="Bob")+(date_range>=date))>0, sum_range) ) }

Evaluation Steps
Step 1: SUM(IF(({FALSE,TRUE,FALSE,TRUE,FALSE}+{FALSE,FALSE,TRUE,TRUE,TRUE})>0,sum_range))
Step 2: SUM(IF({0,1,1,2,1}>0,sum_range))
Step 3: SUM(IF({FALSE,TRUE,TRUE,TRUE,TRUE},sum_range))
Step 4: SUM({FALSE,300,500,0,200})
Step 5: 1000

Using this approach, you can create multiple-criteria equivalents for MAX-IF, LARGE-IF, and other array formulas.

Sequential Number Arrays

For many array formulas, you will need to use an array of sequential numbers like {1; 2; 3; … n}. You can return a sequential number array from 1 to n using this formula:

{ =ROW(1:n) }
-or-
{ =ROW(OFFSET($A$1,0,0,n,1)) }

Important: Although it doesn’t matter what is contained in cell A1, if you delete the cell (by removing row 1 or column A for example), insert a row above or a column to the left of cell A1, or cut and paste cell A1 to a different location, your array formula will be messed up. To avoid this problem, use the INDIRECT function:

{ =ROW(INDIRECT("1:"&n)) }
-or-
{ ROW(OFFSET(INDIRECT("A1"),0,0,n,1)) }

NOTE The OFFSET and INDIRECT function are volatile functions. If calculation speed becomes a problem due to these formulas, you could either use ROW(1:n) and risk having row 1 removed, or you could reference a hidden or protected worksheet using =ROW(Sheet4!1:n)

Variant #1: Create a Sequence of Whole Numbers from i to j

If you want to hard-code the values for i and j into the formula, an array formula such as ROW(4:8) may work fine to create the array {4;5;6;7;8}. If you want the formula to use cell references for i and j, you can use INDIRECT like this:

A1 = 4
B1 = 8
{ =ROW(INDIRECT(A1&":"&B1)) }

Result: {4;5;6;7;8}

Variant #2: Create an n x 1 Vector of Whole Numbers Starting From s

You can use this technique when you want to specify the length of the number array instead of the end value. To create the array {s; s+1; s+2; … s+n-1} use

s = 4
n = 7
{ =s+ROW(OFFSET(INDIRECT("A1"),0,0,n,1))-1 }
   -or-
{ =ROW(INDIRECT(s&":"&s+n-1)) }

Result: {4;5;6;7;8;9;10}

Variant #3: Sequence of Dates Between START and END (inclusive)

To create an array of dates from start through end (assuming start and end are cells containing date values), remember that date values are stored as whole numbers. If they are indeed date values and not date-time values, you can use:

start_date = 1/1/2018
end_date = 1/5/2018
{ =ROW(INDIRECT(start_date&":"&end_date)) }

Result: {43101;43102;43103;43104;43105}

The result shows the numeric values for 1/1/2018, 1/2/2018, etc. You can format the results using whatever date format you want. If your start and end dates might be date-time values, then strip the time portion off of the number like this:

{ =ROW(INDIRECT(INT(start_date)&":"&INT(end_date)) }

Variant #4: Create an n x 1 Vector of Sequential Powers of 10

To create the array {1; 10; 100; 1000; … 10^(n-1)} use

{ =10^(ROW(OFFSET(INDIRECT("A1"),0,0,n,1))-1) }
-or-
{ =10^(ROW(INDIRECT("1:"&n))-1) }

Formulas for Matrices

Excel contains some key functions for working with matrices:

  • MUNIT(m): Creates an Identity matrix of size m x m
  • MMULT(A,B): Uses matrix multiplication to multiply an n x k matrix A by a k x m matrix B resulting in an array of size n x m.
  • TRANSPOSE(A): Switches rows to columns or vice versa, and can be used for more than just numbers.
  • MDETERM(A): Calculates the determinant of a matrix A.
  • MINVERSE(A): Calculates the inverse of the matrix A (if possible).
  • INDEX(A,n) or INDEX(A,0,m): Returns either row n or column m of matrix A.

NOTE Excel does a great job of displaying data, but if you need to do a lot of statistical analysis and linear algebra, other tools such as Python, R, and Matlab may be better.

Element-Wise Multiplication of 2 Matrices

You can perform element-wise multiplication of 2 matrices by simply multiplying two ranges and entering the function as an Array Formula. For example, the formula ={1,2;3,4}*{a,b;c,d} would return the array {1*a,2*b;3*c,4*d}. If one matrix has more columns or rows than the other, those values will be truncated from the result.

Creating the ONES Vector and ONES Matrix

The ones vector j={1;1;1…} and the ones matrix J={1,1;1,1} are very useful in linear algebra and array formulas. The image below shows an example using the MUNIT function to create the Identity matrix I, the ones vector j, and the ones matrix J.

Identity and Ones Matrices in Excel

A simple way to create an n x n ones matrix (J) is to multiply the identity matrix by 0 and add 1, like this:

{ =1+0*MUNIT(n) }

The ones vector (j) of size n x 1 can be created by using INDEX to return the first column of the ones matrix, like this:

{ =INDEX(1+0*MUNIT(n),0,1) }

In older versions of Excel that don’t support the MUNIT function, you can create the ones vector, ones matrix and identity matrix using these formulas:

j =(1+0*ROW(INDIRECT("1:"&n)))
J =IF(ISERROR(OFFSET(INDIRECT("A1"),0,0,n,n)),1,1)
I =IF( ROW(OFFSET(INDIRECT("A1"),0,0,n,n)) = COLUMN(OFFSET(INDIRECT("A1"),0,0,n,n)), 1, 0)

Repeating Rows or Columns to Create a Matrix

Sometimes you may need to form a matrix by repeating a row or column. This can be done using MMULT and the ones vector.

Repeating a Row to Create a Matrix

If you want to create a matrix with n rows by repeating row={1, 2, 3}, use the array formula =MMULT(j,row) where j is size n x 1.

{ =MMULT( INDEX(1+0*MUNIT(n),0,1), row) }

If you want to create a matrix with k columns by repeating col={1;2;3}, use the array formula =MMULT(col,TRANSPOSE(j)) where j is size k x 1.

{ =MMULT(col, TRANSPOSE(INDEX(1+0*MUNIT(k),0,1)) ) }

ROW or COLUMN Sums using the ONES Vector

It turns out that the ONES vector is very important in statistics for performing a very simple matrix operation: summing the rows or columns. Let’s say you have a range of size n (rows) x k (columns). You could either use the SUM function separately for each row or column, or you could use array formulas.

Row and Column Sums Using Array Formulas

Column-Sum: To the sum the values within each COLUMN of the matrix and return the sums as a 1 x n array (or row vector), use

ones_vector =INDEX(1+0*MUNIT(ROWS(range)),0,1)
column_sum =MMULT(TRANSPOSE(ones_vector),range)

Row-Sum: To sum the values within each ROW of the matrix and return the sums as a k x 1 array (or column vector), use

ones_vector =INDEX(1+0*MUNIT(COLUMNS(range)),0,1)
row_sum =MMULT(range,ones_vector)

Creating a DIAGONAL Matrix

Element-wise multiplication of matrices can be used to create a Diagonal matrix. A Diagonal matrix is a special matrix where all of the off-diagonal terms are zeros. To create the Diagonal matrix, you multiply the matrix by the Identity matrix of the same size:

Diagonal =A*MUNIT(ROWS(A))

Many programs (but not Excel) include a function like diag(matrix) which returns an n x 1 vector containing the diagonal terms of an n x n matrix. To return the diagonal as a vector, you can use the row-sum operation on the Diagonal like this:

diag(A) =MMULT(A*MUNIT(ROWS(A)),(1+0*ROW(INDIRECT("1:"&ROWS(A)))))

Find the TRACE of a Square Matrix

The trace of a square matrix is just the sum of the diagonal elements. Therefore, the formula for calculating the trace is just:

trace(A) =SUM( A*MUNIT(ROWS(A)) )

Other Array Formula Examples

Linear Regression

The trend lines in an Excel chart allow you to do simple linear regression, but you can also do linear regression in Excel using matrix and array functions. It’s much easier to just use the LINEST function, but for fun I give the general formula for calculating the b matrix (the least squares estimators) when you have the y and X matrix. Or in other words, if you want to solve for b starting from y=Xb, you can do that using the formula b=(XX)-1Xy which in Excel is:

{ =MMULT(MMULT(MINVERSE(MMULT(TRANSPOSE(x),x)),TRANSPOSE(x)),y) }

Alternate XNPV Function

If for some reason you don’t like Excel’s XNPV function or for some reason you need to use 360 days in a year instead of 365, you can use the following array formula in place of XNPV, where r is the discount rate.

{ =SUM(values_range/((1+r)^((date_range-INDEX(date_range,1))/365))) }

Running XIRR Formula

My Investment Tracker calculates an annualized compounded rate of return using a running XIRR array formula.

Some References for Array Formulas in Excel

  • Guidelines and Examples of Array Formulas at support.office.com
  • Array Formulas at cpearson.com — Some detailed information about using array formulas in Excel, along with some example array functions.
  • Matrix Functions in Excel at bettersolutions.com — Examples showing the use of MDETERM, MINVERSE, MMULT, and TRANSPOSE.
  • Using Excel to find Eigenvalues and Eigenvectors
  • A.C.Rencher, Methods of Multivariate Analysis, John Wiley & Sons, Inc.: New York, 1995.

The array of Excel functions allows you to solve complex tasks in automatically at the same time. We cannot complete the same tasks through the usual functions.

In fact, this is a group of functions that simultaneously process a group of data and immediately produce a result. Let’s consider in detail work with arrays of functions in Excel.



Types of Excel functions

Array is a data grouped together. In this case, the group is an array of functions in Excel. Any table that we compose and fill in Excel can be called an array. Example:

Example.

Depending on the location of the elements, the arrays are distinguished:

  • One-dimensional (data is in ONE line or in ONE column);
  • Two-dimensional (SEVERAL lines and columns, matrix).

One-dimensional arrays are:

  • Horizontal (data in a row);
  • Vertical (data in a column).

Note. Two-dimensional Excel arrays can take several sheets at once (these are hundreds and thousands of data).

Two-dimensional Excel arrays.

Array formula allows you to process data from this array. It can return one value or result in an array (set) of values.

With the help of array formulas it is real to:

  • Count the number of characters in a certain range;
  • Summarize only those numbers that correspond to the given condition;
  • Summarize all n values in a certain range.

When we use array formulas, Excel takes into account the range of values not as individual cells, but as a single data block.



Array formulas syntax

We use the formula of an array with a range of cells and with a separate cell. In the first case, we find the subtotals for the «To pay» «» column. In the second — the total amount of utility payments.

  1. We select the range E3: E8.
  2. Enter the following formula in the formula row: = C3: C8 * D3: D8.
  3. following formula.

  4. Press the keys simultaneously: Ctrl + Shift + Enter. The subtotals are calculated:

subtotals.

The formula after pressing Ctrl + Shift + Enter was in curly brackets. It was automatically inserted into each cell of the selected range.

If you try to change the data in any cell in the «To pay» column, nothing happens. The formula in the array protects range values from changes. A corresponding entry appears on the screen:

To pay.

Consider other examples of using the functions of an Excel array — calculate the total amount of utility payments using a single formula.

  1. Select the cell E9 (opposite the «Total»).
  2. We introduce a formula of the form:
  3. Press the key combination: Ctrl + Shift + Enter. Result:

introduce a formula.

The formula of the array in this case replaced two simple formulas. This is a shortened version, which contains all the necessary information for solving a complex problem.

Arguments for a function are one-dimensional arrays. The formula looks at each of them individually, performs user-defined operations, and generates a single result.

Consider the syntax:

Consider the syntax.

Working functions with Excel array

Let’s guess that it is planned to increase utility payments in 10% the next month. If we introduce the usual formula for the total is =SUM((C3:C8*D3:D8)+10%), then we are unlikely to get the expected result. We need each argument to increase in 10%. For the program to understand this, we use the function as an array.

    understand this.

  1. Let’s have a look how the «И» «AND» operator works in the array function. We need to find out how much we pay for the water, hot and cold. Function:

    The total is 86.46$.

  2. the water price.

  3. The Sort functions in the array formula. Sort the amounts to be paid in ascending order. For the sorted data list, create a range. Let’s select it (F3:F7). In the formula bar, we enter

    Press Ctrl + Shift + Enter.

  4. Sort functions in the array.

  5. The transported matrix. There is a special Excel function for working with two-dimensional arrays. The «ТРАНСП» function returns several values at once. It converts a horizontal matrix to a vertical matrix and vice versa. Select the range of cells where the number of rows equals to the number of columns in the table with the original data. And the number of columns equals to the number of rows in the source array. Select range A9:F10. We introduce the formula:

    Press Ctrl + Shift + Enter. This results in an «inverted» data set.

  6. inverted.

  7. Search for the average without taking into account zeros. If we use the standard «AVERAGE» function, we get «0» as a result. And it will be correct. Therefore, we insert an additional condition into the formula:

We get:

working with arrays.

A common mistake when working with arrays of functions is NOT to press the code combination «Ctrl + Shift + Enter» (never forget this key combination). This is the most important thing to remember when processing large amounts of information. Correctly entered function performs the most complicated tasks.

Download array formula examples

Array formulas are very useful and powerful formulas used to perform some of the very complex calculations in Excel. It is also known as the CSE formula. We need to press “CTRL + SHIFT + ENTER” together to execute array formulas instead of pressing enter. There are two types of array formulas: one that gives us a single result and another that provides multiple results.

For example, suppose you have the data set showing the production and cost for the four products, and you need to calculate the total cost of all the products. We could do this by simply adding formula in the column that multiplies the production and costs of the products and then adding a sum at the bottom of the column. However, the array formulas avoid these steps and provide an answer with a single formula.

Arrays in excelA VBA array in excel is a storage unit or a variable which can store multiple data values. These values must necessarily be of the same data type. This implies that the related values are grouped together to be stored in an array variable.read more can be termed array formulas in Excel. Array in Excel is a powerful formula that enables us to perform complex calculations.

What is an Array? An array is a set of values or variables in a data set like {a,b,c,d} is an array that has values from “a” to “d.” Similarly, in an Excel array is a range of cells of values,

Arrays in Excel example 1

In the above screenshot, cells from B2 to cell G2 are an array or range of cells.

These are also known as “CSE formulas” or “Control Shift Enter Formulas.” For example, for creating an array formula in Excel, we must press “Ctrl + Shift + Enter.”

In Excel, we have two types of array formulas:

  1. One, which gives us a single result.
  2. Another which gives us more than one result.

We will learn both the types of array formulas on this topic.

Table of contents
  • Array Formulas in Excel
    • Explanation of Array Formulas in Excel
    • How to Use Array Formulas in Excel?
    • Example #1
    • Example #2
    • Example #3
    • Things to Remember
    • Recommended Articles

Explanation of Array Formulas in Excel

Array formulas in Excel are powerful formulas that help us perform very complex calculations.

We learned from the above examples that these formulas in Excel simplify complex and lengthy calculations. There is one thing to remember. However, in example 2, we returned multiple values using these formulas in Excel. We cannot change or cut the cell’s value as it is a part of an array.

Suppose we want to delete cell G6 Excel. It will give us an error. Even if we change the value in the cell type, any random value in the cell Excel will provide an error.

For example, type a number in cell G6 and press the “Enter” key. It may provide the following error,

Upon typing a random value 56 in cell G6, it may give an error that we cannot change a part of the array.

If we need to edit an array formula, go to the function bar and edit the provided values or range. If we want to delete the array formula, delete the whole array, i.e., cell range B6 to G6.

How to Use Array Formulas in Excel?

Let us learn an array formula by a few examples:

You can download this Array Formula Excel Template here – Array Formula Excel Template

One can use array formulas in two types:

  1. If we want to return a single value, use these formulas in a single cell, as in example 1.
  2. If we want to return more than one value, use these formulas in Excel by selecting the range of cells as in example 2.
  3. Press CTRL + Shift + Enter to make an array formula.

Example #1

A restaurant’s sales data consists of each product’s price and the number of products sold.

The owner wants to calculate the total sales done by those products.

Arrays Formula in Excel example 1

The owner multiplies the number of items sold for each product then sums them up as in the given-below equation,

Arrays Formula in Excel example 1-1

Also, he gets the total sales as given below:

Arrays Formula in Excel example 1-2

But this is a lengthy task. If the data were bigger, it would be much more tedious. So instead, Excel offers array of formulas for such tasks.

Arrays Formula in Excel example 1-3

We will create our first array formula in cell B7.

The following are the steps to make the first array: –

  1. In cell B7, type =SUM and press the “tab” button on the keyboard. It may open up the sum formula.

    Arrays Formula in Excel example 1-4

  2. Select the cell range from B2 to G2.

    Arrays Formula in Excel example 1-5

  3. Now, put an asterisk “*” sign after B2:G2 to multiply.

    Arrays Formula in Excel example 1-6

  4. Select the cell range from B3 to G3.

    Arrays Formula in Excel example 1-7

  5. Instead of pressing the “Enter” key, press “CTRL + SHIFT + ENTER.”

    Arrays Formula in Excel example 1-8

    As a result, Excel may provide the total sales value by multiplying the number of products by the price in each column and summing them up. For example, in the highlighted section, we can see that Excel has created an array for cell range B2 to G2 and B3 to G3.

    Arrays Formula in Excel example 1-9

    The above example explains how Excel array formulas return a single value for an array or set of data.

Example #2

With the same data, what if the owner wants to know the sales for each product separately, like sales of products 1 and 2?

Arrays Formula in Excel example 2

He can either go a long way. In each cell, perform a function that will calculate the sales value.

Arrays Formula in Excel example 2-1

The equation mentioned in cell B5 will be required to repeat for cells C4, D4, etc.

Again, it would be a tedious task if it were larger data.

In this example, we will learn how array formulas in Excel return multiple values for a set of arrays.

Example 2-2

#1 – Select the cells where we want our subtotals, i.e., per product sales for each product. In this case, it is a cell range B8 to G8.

Example 2-3

#2 – Type an equal to sign “=” a

Example 2-4

#3 –Select cell range B2 to G2.

Example 2-5

#4 – Type an asterisk “*” sign after B2:G2.

Example 2-6

#5 – Now, select cell range B3 to G3.

Example 2-7

#6 – Do not press the “Enter” key for the array formula. Press “CTRL + SHIFT + ENTER” for array formula.

Example 2-8

The above example explains how an array formula can return multiple values for an array in Excel.

Cells B6 to G6 are an array.

Example #3

For the same restaurant owner, he has the restaurant sales data for six months Jan, Feb, March, April, May, and June. He wants to know the average growth rate for sales.

Example 3

The owner can normally subtract the sales value of Feb month to Jan in cell C2 and then calculate the average.

Example 3-1

Again, it would be a tiresome task if this were larger data. So let us do this with the array in Excel formulas.

#1 – In cell D8, type =average. Then, press the “tab” button.

Example 3-2

#2 – To calculate growth, we will need to subtract the values of one month from the previous month to select the cell range from B3 to B7.

Example 3-3

#3 – Put a subtract (-) sign after B3:B7,

Example 3-4

#4 – Now, select cells from B2 to B6.

Example 3-5

#5 – As for the array in Excel, do not press the “Enter” key. Press “CTRL + SHIFT + ENTER.

Example 3-6

Array formulas in Excel easily calculated the average growth for the sales without any hassle.

The owner now does not require calculating each month’s growth and performs the average function after that.

Things to Remember

  1. These are also known as CSE Formulas or Control Shift Enter ExcelCtrl-Shift Enter In Excel is a shortcut command that facilitates implementing the array formula in the excel function to execute an intricate computation of the given data. Altogether it transforms a particular data into an array format in excel with multiple data values for this purpose.read more Formulas.
  2. Do not make parenthesis for an array; Excel itself does that. It would return an error or incorrect value.
  3. Entering the parenthesis “{“manually, Excel will treat it as a text.
  4. Do not press the “Enter” key. Instead, press “CTRL + SHIFT + Enter” to use an array formula.
  5. We cannot change the cell of an array. So, to modify an array formula, either modify the formula from the function bar or delete the formula and redesign it in the desired format.

Recommended Articles

This article is a step-by-step guide to Array formulas in Excel. Here, we discuss how to use array in Excel using basic SUM and AVERAGE formulas and use it to solve array in Excel along with Excel examples and downloadable Excel templates. You may also look at these useful functions in Excel: –

  • What is Name Range in Excel?
  • Redim Array in Excel VBA
  • Excel Formula Cheat Sheet
  • VBA Array Function

An array formula is a type of formula that performs an operation on multiple values instead of a single value. The final result of an array formula can be either one item or an array of items, depending on how the formula is constructed. For example, the following formula is an array formula that returns the sum of all characters in a range:

{=SUM(LEN(range))}

To work correctly, many (but not all) array formulas need to be entered with control + shift + enter. When you enter with control + shift + enter, you’ll see the formula wrapped in curly braces {} in the formula bar. Do not enter curly braces manually, or the formula won’t work.

What is an Array?

An array is a collection of more than one item. Arrays in Excel appear inside curly brackets. For example, {1;2;3} or {«red»,»blue»,»green»}. The reason arrays are so common in Excel is that they map directly to cell ranges.  Vertical ranges are represented as arrays that use semicolons, for example {100;125;150}. Horizontal ranges are represented as arrays that use commas, for example {«small»,»medium»,»large»}. A two dimensional range will use both semicolons and commas.

Examples

Array formulas are somewhat difficult to understand, because the terminology is dense and complex. But array formulas themselves can be very simple. For example, this array formula tests the range A1:A5 for the value «a»:

{=OR(A1:A5="a")}

The array operation is the comparison of each cell in A1:A5 to the string «a». Because the comparison operates on multiple values, it returns multiple results to the OR function:

=OR({FALSE;FALSE;FALSE;TRUE;FALSE})

If any item in the resultant array is TRUE, the OR function returns TRUE.

Sometimes array formulas supply multiple values as a function argument. For example, this array formula returns the total character count in the range B2:B11:

{=SUM(LEN(B2:B11))}

The LEN function is given multiple values in the range B2:B11 and returns multiple results in an array like this inside SUM:

=SUM({3;3;5;4;5;4;6;5;4;4})

where each item in the array represents the length of one cell value.  The SUM function then sums all items and returns 43 as the final result.

Special syntax

In all versions of Excel except Excel 365, many array formulas need to be entered in a special way to work correctly. Instead of entering with the the «Enter» key, they need to be entered with Control + Shift + Enter. You’ll sometimes see Control + Shift + Enter abbreviated as «CSE», as in «CSE formula». A formula entered in this way will appear with curly braces on either side:

={formula}

These braces are displayed automatically by Excel. Make sure you do not enter the curly braces manually!

Not all array formulas need to be entered with  Control + Shift + Enter. Certain functions, like SUMPRODUCT, are programmed to handle array operations natively and usually don’t require Control + Shift + Enter.  For example, both formulas below are array formulas that return the same result, but only the SUM version requires Control + Shift + Enter:

={SUM(LEN(A1:A5))}
=SUMPRODUCT(LEN(A1:A5))

Excel 365

In Excel 365, array formula are native and do not require control + shift + enter. For a general introduction, see Dynamic Array Formulas in Excel.

Содержание

  • Операции с массивами
    • Создание формулы
    • Изменение содержимого массива
  • Функции массивов
    • Оператор СУММ
    • Оператор ТРАНСП
    • Оператор МОБР
  • Вопросы и ответы

Массив в программе Microsoft Excel

Во время работы с таблицами Excel довольно часто приходится оперировать с целыми диапазонами данных. При этом некоторые задачи подразумевают, что вся группа ячеек должна быть преобразована буквально в один клик. В Экселе имеются инструменты, которые позволяют проводить подобные операции. Давайте выясним, как можно управлять массивами данных в этой программе.

Операции с массивами

Массив – это группа данных, которая расположена на листе в смежных ячейках. По большому счету, любую таблицу можно считать массивом, но не каждый из них является таблицей, так как он может являться просто диапазоном. По своей сущности такие области могут быть одномерными или двумерными (матрицы). В первом случае все данные располагаются только в одном столбце или строке.

Одномерный массив в Microsoft Excel

Во втором — в нескольких одновременно.

Двумерный массив в Microsoft Excel

Кроме того, среди одномерных массивов выделяют горизонтальный и вертикальный тип, в зависимости от того, что они собой представляют – строку или столбец.

Горизонатльные и вертикальные одномерные массивы в Microsoft Excel

Нужно отметить, что алгоритм работы с подобными диапазонами несколько отличается от более привычных операций с одиночными ячейками, хотя и общего между ними тоже много. Давайте рассмотрим нюансы подобных операций.

Создание формулы

Формула массива – это выражение, с помощью которого производится обработка диапазона с целью получения итогового результата, отображаемого цельным массивом или в одной ячейке. Например, для того, чтобы умножить один диапазон на второй применяют формулу по следующему шаблону:

=адрес_массива1*адрес_массива2

Над диапазонами данных можно также выполнять операции сложения, вычитания, деления и другие арифметические действия.

Координаты массива имеют вид адресов первой её ячейки и последней, разделенные двоеточием. Если диапазон двумерный, то первая и последняя ячейки расположены по диагонали друг от друга. Например, адрес одномерного массива может быть таким: A2:A7.

Адрес одномерного массива в Microsoft Excel

А пример адреса двумерного диапазона выглядит следующим образом: A2:D7.

Lumpics.ru

Адрес двумерного массива в Microsoft Excel

  1. Чтобы рассчитать подобную формулу, нужно выделить на листе область, в которую будет выводиться результат, и ввести в строку формул выражение для вычисления.
  2. Введение формулы массива в Microsoft Excel

  3. После ввода следует нажать не на кнопку Enter, как обычно, а набрать комбинацию клавиш Ctrl+Shift+Enter. После этого выражение в строке формул будет автоматически взято в фигурные скобки, а ячейки на листе будут заполнены данными, полученными в результате вычисления, в пределах всего выделенного диапазона.

Результат вычислений формулы массива в Microsoft Excel

Изменение содержимого массива

Если вы в дальнейшем попытаетесь удалить содержимое или изменить любую из ячеек, которая расположена в диапазоне, куда выводится результат, то ваше действие окончится неудачей. Также ничего не выйдет, если вы сделаете попытку отредактировать данные в строке функций. При этом появится информационное сообщение, в котором будет говориться, что нельзя изменять часть массива. Данное сообщение появится даже в том случае, если у вас не было цели производить какие-либо изменения, а вы просто случайно дважды щелкнули мышью по ячейке диапазона.

Нельзя изменять часть массива в Microsoft Excel

Если вы закроете, это сообщение, нажав на кнопку «OK», а потом попытаетесь переместить курсор с помощью мышки, или просто нажмете кнопку «Enter», то информационное сообщение появится опять. Не получится также закрыть окно программы или сохранить документ. Все время будет появляться это назойливое сообщение, которое блокирует любые действия. А выход из ситуации есть и он довольно прост

  1. Закройте информационное окно, нажав на кнопку «OK».
  2. Закрытие информационного окна в Microsoft Excel

  3. Затем нажмете на кнопку «Отмена», которая расположена в группе значков слева от строки формул, и представляет собой пиктограмму в виде крестика. Также можно нажать на кнопку Esc на клавиатуре. После любой из этих операций произойдет отмена действия, и вы сможете работать с листом так, как и прежде.

Отмена действия в Microsoft Excel

Но что делать, если действительно нужно удалить или изменить формулу массива? В этом случае следует выполнить нижеуказанные действия.

  1. Для изменения формулы выделите курсором, зажав левую кнопку мыши, весь диапазон на листе, куда выводится результат. Это очень важно, так как если вы выделите только одну ячейку массива, то ничего не получится. Затем в строке формул проведите необходимую корректировку.
  2. Внесение изменений в формулу массива в Microsoft Excel

  3. После того, как изменения внесены, набираем комбинацию Ctrl+Shift+Esc. Формула будет изменена.

Изменения в формулу массива внесены в Microsoft Excel

  1. Для удаления формулы массива нужно точно так же, как и в предыдущем случае, выделить курсором весь диапазон ячеек, в котором она находится. Затем нажать на кнопку Delete на клавиатуре.
  2. Удаление формулы массива в Microsoft Excel

  3. После этого формула будет удалена со всей области. Теперь в неё можно будет вводить любые данные.

Формула массива удалена в Microsoft Excel

Функции массивов

Наиболее удобно в качестве формул использовать уже готовые встроенные функции Excel. Доступ к ним можно получить через Мастер функций, нажав кнопку «Вставить функцию» слева от строки формул. Или же во вкладке «Формулы» на ленте можно выбрать одну из категорий, в которой находится интересующий вас оператор.

Переход к функциям в Microsoft Excel

После того, как пользователь в Мастере функций или на ленте инструментов выберет наименование конкретного оператора, откроется окно аргументов функции, куда можно вводить исходные данные для расчета.

Правила ввода и редактирования функций, если они выводят результат сразу в несколько ячеек, те же самые, что и для обычных формул массива. То есть, после ввода значения обязательно нужно установить курсор в строку формул и набрать сочетание клавиш Ctrl+Shift+Enter.

Урок: Мастер функций в Excel

Оператор СУММ

Одной из наиболее востребованных функций в Экселе является СУММ. Её можно применять, как для суммирования содержимого отдельных ячеек, так и для нахождения суммы целых массивов. Синтаксис этого оператора для массивов выглядит следующим образом:

=СУММ(массив1;массив2;…)

Функция СУММ в Microsoft Excel

Данный оператор выводит результат в одну ячейку, а поэтому для того, чтобы произвести подсчет, после внесения вводных данных достаточно нажать кнопку «OK» в окне аргументов функции или клавишу Enter, если ввод выполнялся вручную.

Урок: Как посчитать сумму в Экселе

Оператор ТРАНСП

Функция ТРАНСП является типичным оператором массивов. Она позволяет переворачивать таблицы или матрицы, то есть, менять строки и столбцы местами. При этом она использует исключительно вывод результата в диапазон ячеек, поэтому после введения данного оператора обязательно нужно применять сочетание Ctrl+Shift+Enter. Также нужно отметить, что перед введением самого выражения нужно выделить на листе область, у которой количество ячеек в столбце будет равно числу ячеек в строке исходной таблицы (матрицы) и, наоборот, количество ячеек в строке должно равняться их числу в столбце исходника. Синтаксис оператора следующий:

=ТРАНСП(массив)

Функция ТРАНСП в Microsoft Excel

Урок: Транспонирование матриц в Excel

Урок: Как перевернуть таблицу в Экселе

Оператор МОБР

Функция МОБР позволяет производить вычисление обратной матрицы. Все правила ввода значений у этого оператора точно такие же, как и у предыдущего. Но важно знать, что вычисление обратной матрицы возможно исключительно в том случае, если она содержит равное количество строк и столбцов, и если её определитель не равен нулю. Если применять данную функцию к области с разным количеством строк и столбцов, то вместо корректного результата на выходе отобразится значение «#ЗНАЧ!». Синтаксис у этой формулы такой:

=МОБР(массив)

Функция МОБР в Microsoft Excel

Для того чтобы рассчитать определитель, применяется функция со следующим синтаксисом:

=МОПРЕД(массив)

Функция МОПРЕД в Microsoft Excel

Урок: Обратная матрица в Excel

Как видим, операции с диапазонами помогают сэкономить время при вычислениях, а также свободное пространство листа, ведь не нужно дополнительно суммировать данные, которые объединены в диапазон, для последующей работы с ними. Все это выполняется «на лету». А для преобразования таблиц и матриц только функции массивов и подходят, так как обычные формулы не в силах справиться с подобными задачами. Но в то же время нужно учесть, что к подобным выражениям применяются дополнительные правила ввода и редактирования.

Excel is among the most powerful and widely used spreadsheet tools which eases organizing numbers and data within the sheets with pre-built formulas and functions. In this article, we are going to study Array Formulas. Arrays are one of them. Using Excel Array Formulas, make it super easy to handle a lot of data. Before understanding and using the Array formulas, let’s first understand what is Array in Excel?

Array in Excel

An Array in Excel is the structure that holds a collection of data. These data can be in the form of numbers or texts. There could be an array of 1-D or 2-D as well in Excel. For example, the array of fruits in excel would be written something like this:-

{“Apple”, “Banana”, “Grapes”, “Guava”}

We can directly enter it into the sheet by selecting the cells where you want to enter the data and then writing the array preceded by an “=” sign.  After these press Ctrl+Shift+Enter. For example, let’s enter these values in cells A1 to D1.

Array-in-excel

The array created here is a horizontal array. You can also create a vertical array by changing the selected cells. You can create an array by specifying the starting and the ending positions, for example, if you wish to make an array of elements between A1 to F1 then you can write A1:F1. Now. let’s move to array formulas.

Array formulas

Array formulas enable to process of several values and give several outputs. In a simple world, it can do multiple calculations and reduce a lot of human efforts. In other words, we can say that it solves array calculations and give an array as output too. Let’s understand more of them with an example, of students with their test marks,

Sample-data

Here, we have used a formula to evaluate the result in the ‘Total’ field. For inserting the formula, click on the cell where you want to store the answer and write the formula. Now, let’s try to calculate the same for all students

Using-Array-formula

For calculating the total for all the students, select the field where you want to store them, now select the range, and insert the formula. Array formulas are available in every version of Excel, so you don’t worry about your excel version. There are hundreds of operations possible using array formulas, which we will discuss in this article later. But before proceeding let’s understand what is the need to use an array formula.

Why use an Array Formula?

Array formulas are to most powerful yet most easy-to-use calculation tools which could be used to perform complex calculations and take place of hundreds of formulas with a single formula. You can further specify conditions for the calculation of data. Not just calculations you can also count the chars in cells, add date, day, or time, and even pick random data. 

How to insert an Array Formula?

Before entering the Array formula fir of all we understand some important points about the Array formula:

  • After typing the formula you have to press keys CTRL+SHIFT+ENTER together. It will automatically change the normal formula into an array formula. 
  • If you manually type braces around the formula then it will not convert the formula into an array formula. You have to use CTRL+SHIFT+ENTER keys to convert the formula into an array formula.
  • Whenever you edit the array formula the braces will disappear automatically and you have to again press the combination of CTRL+SHIFT+ENTER keys.
  • If you forget to press the CTRL+SHIFT+ENTER keys then your formula will work as the normal formula.

Now let’s understand inserting an array formula.

Single Cell Array formula

Every array formula returns the result in either single or in multiple cells. So when an array formula returns its result in the single-cell then such type of formula is known as a single-cell array formula. Such types of formulas are SUM, AVERAGE, AGGREGATE, MAX, MIN, etc. Follow the following steps to use the single-cell array formula:

Step 1: Select the cell where you want to store the answer.

Step 2: Now go to the formula bar and write an “=” sign.

Step 3: Now to formulas (highlighted below), and select the operation you want to perform.

Single-cell-array

Step 4: Here we want to perform the sum operation. Click on sum and a new popup will open. Write the cells you want to perform the operation with.

Function-arguments

Multi-Cell Array Formula

If you wish to perform the same calculation with more cells then you can use the multi-cell formula. You can implement it in two ways. Functions like TRANSPOSE, TREND, FREQUENCY, LINEST, etc are used for the multi-cell arrays. Implement the formula in single-cell by following the above steps. Now, drag the selection up to the cells you want to implement the formula. Below is the implementation of doing that.

Multi-cell-array-formula

Alternatively,

Specify the range of cells and an operator between them. For example, =(B1:B7 + C2:C7) and press Ctrl+Shift+Enter. 

Operator-in-multi-cell

Excel Array Constants

Excel array contacts are a set of static values and can’t be changed. These values remain constant regardless of the operations performed on them. Now we will see how to create Array Constants in Excel and will perform different actions on them. There are three types of array constant available:

1. Horizontal or Row Array constant

A horizontal constant is present in a row. To create a horizontal constant we have to type multiple values separated by a comma in the enclosed braces. To enter a row array follow these steps below:

Step 1: Select the cells you want to work with.

Step 2: Go to the formula bar and start with an equal sign. 

Step 3: Now enter the array you want to create in braces {}, separated by commas(,). Ex:- ={1,2,3,4,5}

Step 4: Now press Ctrl+Shift+Enter.

Horizontal-or-Row-Array-constant

2. Vertical or Column Array

Vertical array constants are generally present in Column Array. To create a vertical constant we have to type multiple values separated by a semicolon in the enclosed braces. To enter a column array follow these steps below:

Step 1: Select the cells you want to work with.

step 2: Go to the formula bar and start with an equal sign. 

Step 3: Now enter the array you want to create in braces {} separated with termination sign(;). Ex:- ={“Coding”;”GFG”;”GeeksforGeeks”}

Step 4: Now press Ctrl+Shift+Enter.

 Vertical-or-Column-Array

3. 2-D array

In Excel, you are allowed to create a 2-D array. So to create a 2-D array constant, we have to type multiple values in which rows are separated by semicolons and d columns are separated by commas. Let’s understand the implementation of a 2-d array. 

Step 1: Select the cells you want to work with.

Step 2: Go to the formula bar and start with an equal sign. 

Step 3: Now enter the array you want to create in braces {} separated with commas(,) for entering the values in same row, termination sign(;) for row change. Ex:- ={1,2,3;”Coding”,”GFG”,”GeeksforGeeks”}

Step 4: Now press Ctrl+Shift+Enter.

Working with Constant arrays

In the Excel formula, array constants are the important part. Some of the important concepts of Array constant are:

1. Elements: To create elements of array constant we have to follow the following points:

  1. The elements of an array constant must be of numeric, alphabetic, boolean, or scientific notation and each of them is separated by commas or semicolons.
  2. The elements of an array constant do not contain an array, cell reference, dates functions formulas, defined names, etc.
  3. You can also be allowed to use text in the array of the element but the text is surrounded by hyphens(“”). 

2. Naming Array Constants: You can name any array and use them as a variable for further references. For naming an array, follow the steps below:

  1. Go to the formula tab. and select Define Name.
  2. Write the array name in the name. You can also add some comments related to your array.
  3. Click on OK.

3. Common Errors: Following are the common errors that will happen while working with array constants:

  1. The use of delimiters in between the elements.
  2. The selection of range is also an important point to remember. 

Unary Operator in Excel Array Formulas

Using unary operators we can process the array using AND and OR operators. 

  1. AND: It is denoted by an asterisk(*) symbol. It returns true if and only if all conditions are true, 
  2. OR: It is denoted by a plus(+) symbol. It returns true if any of the statement is true.

These operators are more useful when you have the same variable with a different value. For example, let’s consider a case, where data of 3 sellers of different months are given and you have to how much Shyam sold potatoes.

Using-and-operator

Excel worksheet arrays and vectors

This material about arrays and vectors involves three concepts:

  1. Excel structures able to hold data, most commonly, the array of cells on a worksheet (by reference, name or constant)
  2. mathematical element wise array operations, and
  3. matrix based linear algebra array operations

An array can be described as a group of items that can be acted on either individually or collectively. An array’s orientation is classified by its dimension (such as column orientation, or row orientation, discussed further in section 1). In Excel the concept is best illustrated by example, see figure 1 (worksheet: WS arrays) where «a group of items» means a contiguous range, In particular, an array can be a:

  • Scalar — a single cell
  • Column array (column vector) — range B2:B7 shaded green
  • Row array (row vector) — range B9:E9 shaded blue
  • Multi dimensional array — range B11:D14 shaded grey

The expressions «scalar», «row vector» and «column vector» are common to the MatLab (matrix laboratory) application software.

array row col multidim

Fig 1: Column, Row and MultiDimensional array — CollArr (6R x 1C), RowArr (1R x 4C), and MDArr (4R x 3C) 12 elements

1. Arrays — concepts

Dimension

The size of an array is described by the number of rows and number of columns. By convention the dimension is always rows first and columns second, in the spirit of R1C1 reference style, and the ordering of row and column arguments in functions such as INDEX and OFFSET.

Excel uses [mR x nR] during selection resizing operations (m and n are common to MatLab). MatLab uses m x n notation, with m being the number of rows (first dimension) and n being the number of columns (second dimension). Thus [2R x 3C] is a 2 row by 3 column array.

An array is contiguous, meaning rectangular / square, and a worksheet array can be referenced by the top left cell and bottom right cell with the range operator, see B11:DF14 in figure 1. Some functions return an array (eg. the TRANSPOSE and MMULT functions).

Dimensions (from figure 1):

  • Scalar: dimension 1 x 1 (not shown in figure)
  • Column vector: named ColArr, dimension 6 x 1, number of elements 6
  • Row vector: named RowArr, dimension 1 x 4, number of elements 4
  • MultiDimensional array: a two dimensional array named MDArr, dimension 4 x 3, number of elements 12

In mathematics, the arrays in figure 1 can presented in the form:

$$text{ColArr}=begin{bmatrix} r1 \ r2 \ r3 \ r4 \ r5 \ r6 end{bmatrix},
qquad text{RowArr}=begin{bmatrix} c1 & c2 & c3 & c4 end{bmatrix}
qquad text{MDArr}=begin{bmatrix} r1c1 & r1c2 & r1c3 \ r2c1 & r2c2 & r2c3 \ r3c1 & r3c2 & r3c3 \ r4c1 & r4c2 & r4c3 end{bmatrix}$$

where [ ] represents the array.

Name Manager curly braces «{}»

In Excel there are two representations of arrays:

  1. the worksheet depiction in figure 1, and
  2. computer memory depictions such as the Value and Refers To field of the Name Manager (figure 2)

stored and  named constant array

Fig 2: Name Manager — with details of Row, Column, and MultiDimensional arrays (1), and an array constant (2)

Value field

The three arrays from figure 1 are stored arrays link and are labeled in figure 2

  • Excel arrays use opening «{» and closing «}» curly braces
  • Arrays are constructed on a row by row basis
  • Individual elements are separated by a comma «,»
  • End of row is marked by a semi-colon «;» except for the last row
  • These formats do not apply to a scalar

In Excel array notation:

  1. Name: ColArr; Value: {"r1";"r2";"r3";"r4";"r5";"r6"}
  2. Name: RowArr; Value: {"c1","c2","c3","c4"}
  3. Name: MDArr; Value: {"r1c1","r1c2","r1c3";"r2c1","r2c2","r2c3";"r3c1","r3c2","r3c3";"r4c1","r4c2","r4c3"}

«Refers To» field

The array ArrConst, labeled in figure 2 is a named array constant. It has 2 x 2 dimension and is used in the Named Array Const worksheet in figure 3.

named array constant

Fig 3: Named Array constant — named ArrConst with dimension 2 x 2

In Excel array notation, the named array constant has:

  1. Name: ArrConst;
  2. Value: {...} curly braces with a horizontal ellipses;
  3. Refers To: {"A",1;"XFD",1048576}

To enter the array, select a 2 x 2 range, type =ArrConst in the Formula Bar, then press Control + Shift + Enter to complete the formula.

A named array constant

  • can contain numbers, text, logical values (TRUE and FALSE) and error values (like #N/A!)
  • all text must be in double quotes «»
  • cannot contain other arrays, formulas, or functions
  • percentages must be decimal or text (0.10 or «10%»)

Function Arguments curly braces «{}»

Array values are displayed in the Function Arguments dialog box to the right of the argument name (figure 4). A maximum of 36 characters are shown.

function arguments curly braces

Fig 4: Function Arguments — with details of Column vector CollArr from figure 2, demonstrated with the COUNTA function

Formula F2 F9 curly braces «{}»

You can check the values in an array (or reference) with the F2 F9 sequence. In figure 5, the cell F2 has the formula =COUNTA(ColArr). To check the values in the array

  1. switch to Edit mode by pressing F2
  2. select the reference ColArr in the Formula Bar
  3. press F9 to debug part of a formula. The result is displayed in the figure
  4. this technique is limited by the formula maximum of 8,192 characters (2 ^ 13)

function arguments curly braces

Fig 5: Formula with an array argument — the Column vector ColArr, in Edit mode (F2) Select F9 to debug part of a formula ie. view the array

2. Arrays — element wise operators

Operations on an array, as described in section 2, requires an array formula which has several distinct features compared to a conventional formula in Excel.

  • An array formula is completed by pressing the CONTROL + SHIFT + ENTER key sequence often referred to by the abbreviation CSE formula
  • There two distinct types of operations involving arrays
    1. Element by element, and
    2. Matrix (based on linear algebra)
  • Only element by element is covered in this module
  • (Generally) Each array must have the same magnitude and direction. In other words, the name dimension (excluding 1 x 1 scalar arrays)
  • You cannot edit or delete part of an array. You must select the current array — use the Ctrl + / shortcut, or

Example — Excel Online #1

From the «element wise» worksheet in figure 6. The example uses two row vectors each of dimension (1 x 3). The range names of the arrays and values are: x = [1,2,3], and y = [4,5,6], and they appear in rows 4 and 5 of figure 6

WS1: the element wise worksheet demonstrates:

  1. Addition
  2. Subtraction
  3. Multiplication
  4. Division
  5. Scalar addition
  6. Scalar subtraction
  7. Scalar multiplication
  8. Scalar division
  9. Scalar exponentiation
  10. Scalar logical

Fig 6: Excel Online #1WS1: element by element array operations (1 to 4), and element by scalar constant (5 to 10), WS2: — Units x Price to Sales example. WS3: — 100 records no IF filter WS4: NPV using the VisiCalc handbook numbers and the xlf Carrot Washer example

WS2: The U x P >> Sales worksheet demonstrates a small data base of Unit number and Price data, the user is required to:

  1. Calculate Total Sales using normal cell formulae and the SUM function
  2. Calculate Total Sales using CSE formulae for sales then SUM
  3. Calculate Total Sales using CSE formulae in the final cell
  4. Repeat step 3 using the Excel SUMPRODUCT function

Each vector is 6 x 1.

WS3: The 100 records no IF filter worksheet uses the 100 records data base to demonstrate vector logical CSE formulas. Required:

  1. Sum product A, B and C for Salesperson = "Wong"
  2. Sum product A, B and C for Salesperson = "Wong" AND Month = "September"
  3. Sum product A for Salesperson = "Wong" AND Product A >= 10 AND Product A <= 30

Each field column uses the label as vector name. For example, the Invoice No field has vector name Invoice_No

The CSE formulas are (in Ready mode):

  1. {=SUM((Salesperson = "Wong") * Prod_C_qty)}
  2. {=SUM((Salesperson="Wong") * (Month="September") * Prod_C_qty)}
  3. {=SUM((Salesperson="Wong") * (Prod_A_qty >= 10) * (Prod_A_qty <= 30) * Prod_A_qty)}

WS4: The NPV as CSE worksheet uses using the VisiCalc handbook numbers, and the xlf Carrot Washer example.

The technique is a direct interpretation of the NPV equation —
$$begin{equation} NPV=sum_{t=0}^{n} frac{C_t}{(1+k)^t} end{equation}$$ where the initial cash flow at time zero and future cash flows at time (t) are denoted (C_t) over (n) periods. (k) is the periodic discount rate.

Using equation 1, the application is:

The VisiCalc example
$$ NPV=frac{-20,000}{(1+0.1)^{0}} + frac{3,000}{(1+0.1)^{1}} + frac{7,500}{(1+0.1)^{2}}+ frac{15,000}{(1+0.1)^{3}}+ frac{25,000}{(1+0.1)^{4}}+ frac{30,000}{(1+0.1)^{5}} = $35,898 $$

The carrot washer example
$$ NPV=frac{-80,000}{(1+0.05)^{0}} + frac{10,000}{(1+0.05)^{1}} + frac{20,000}{(1+0.05)^{2}}+ frac{15,000}{(1+0.05)^{3}}+ frac{50,000}{(1+0.05)^{4}}+ frac{20,000}{(1+0.05)^{5}} = $17,428 $$

array formula NPV

Fig 7: Formula with an array argument — the Column vector ColArr, in Edit mode (F2) Select F9 to debug part of a formula ie. view the array

The CSE formulas for the NPV estimates are:

  1. VisiCalc =SUM(Cashflows / (1 + Disc) ^ {0;1;2;3;4;5}) returns 35,898.32, where {0;1;2;3;4;5} is an array constant (column orientation 6 by 1)
  2. carrot washer =SUM(Cashflows2 / (1 + Disc2) ^ (ROW(1:6) - 1)) returns 17,427.61
  • Development platform: Excel 2016 (64 bit) Office 365 ProPlus on Windows 10
  • Related material: Add a series of relative offset names to the Name Manager
  • O’Connor I, (2015) Convert lower triangle table to full matrix. Includes discussion of array / matrix dimension and element indexing
  • O’Connor I, (2017) Excel functions with array arguments. Includes array (CSE) and enter formulas
  • O’Connor I, (2015) Vector to array constant. Includes VBA code for text based vector
  • Revised: Saturday 25th of February 2023 — 10:12 AM, [Australian Eastern Time (AET)]

Author: Oscar Cronquist Article last updated on February 10, 2023

This article explains the basics of array formulas, read this article if you never have used array formulas before. It opened up a new world to me and I am sure you will find many applications for these kinds of calculations.

What’s on this webpage

  1. Why are array formulas so powerful?
  2. How to identify array formulas?
  3. How to enter an array formula?
  4. Why is only one value shown? I have x values in the array?
  5. What are vertical and horizontal arrays?
  6. How to use cell references in array formulas?
  7. How to quickly build an array
  8. How to hard code (literal) values in array formulas?
  9. Is Ctrl + Shift + Enter always necessary?
  10. Can I enter an array formula in merged cells?
  11. Are there any exceptions?
  12. Any caveats with array formulas?
  13. Alright, show me some useful array formulas?
  14. Excel 365 dynamic array formulas
  15. Get Excel file

1. Why are array formulas so powerful?

A beginners guide to Excel array formulas 1

They allow you to do things not possible with regular formulas, an array formula can do multiple calculations based on several values simultaneously. You can do some seriously complicated calculations, Excel is definitively a powerful tool.

The array formula example, demonstrated in the image above, performs calculations to multiple numbers simultaneously and returns the smallest number from those calculations.

It multiplies all numbers in column B with all numbers in column D and returns the smallest product of all numbers.

Array formula in cell D9:

=MIN(B3:B7*TRANSPOSE(D3:D6))

Explaining formula in cell D9

Step 1 — Transpose numbers

It is not possible to multiply two vertical arrays containing a different amount of numbers. The TRANSPOSE function converts a vertical array to horizontal and vice versa.

However, if they were of identical size the result would not be what we are looking for anyway, the first number would be multiplied with the first value in the second array only. We want each value multipled with all numbers in the second array to calculate all combinations.

TRANSPOSE(D3:D6)

becomes

TRANSPOSE({1.4;5.2;4.2;0.7})

and returns {1.4,5.2,4.2,0.7}.

Note that the delimiting character is a semicolon in the vertical array and a comma in the horizontal array.

A beginners guide to Excel array formulas transpose numbers

The image above shows the numbers in the second array arranged horizontally.

Step 2 — Multiply numbers

B3:B7*TRANSPOSE(D3:D6)

becomes

B3:B7*{1.4,5.2,4.2,0.7}

becomes

{4;3;6;0.5;5}*{1.4,5.2,4.2,0.7}

and returns {5.6,20.8,16.8,2.8;4.2,15.6,12.6,2.1;8.4,31.2,25.2,4.2;0.7,2.6,2.1,0.35;7,26,21,3.5}.

A beginners guide to Excel array formulas multiply numbers

The result is shown in cell range H3:K7 in the image above. Cell H3 shows the product of the numbers in cell H2 and G3, and so on.

Step 3 — Extract the smallest number in the array

The MIN function returns the smallest number from a cell range or an array.

MIN(B3:B7*TRANSPOSE(D3:D6))

becomes

MIN({5.6,20.8,16.8,2.8;4.2,15.6,12.6,2.1;8.4,31.2,25.2,4.2;0.7,2.6,2.1,0.35;7,26,21,3.5})

and returns 0.35 which is the smallest number in the array.

A beginners guide to Excel array formulas smallest numbers

The image below shows the result in cell D9, all these calculations were completed in one cell only.

A beginners guide to Excel array formulas 1

Back to top

2. How to identify array formulas?

A beginners guide to Excel array formulas identify an array formula 1

The formula bar is above your worksheet, it may be empty or contain a value or a formula. The image above demonstrates an array formula in cell D9.

The formula bar shows what kind of formula the selected cell contains. An array formula begins with a curly bracket and ends with a curly bracket.

These curly brackets appear automatically if you enter the formula as an array formula, see next section below on how to do that.

3. How to enter an array formula?

Constructing an array in Excel is easy. Double press with left mouse button on cell A1 and type ={1,2,3} in the formula bar and hold and press CTRL + SHIFT simultaneously, then press Enter once. Release all keys.

The formula in the formula bar now shows a beginning and ending curly bracket. Don’t enter those characters yourself. Make sure the formula bar looks like this: {={1,2,3}}

excel arrays

If your formula bar looks like the picture above then you have made your first array! If not try again.

={1,2,3} is an array of constants separated by a delimiting character. This formula is entered in cell A1 but only one value in the array is displayed, why is that? The next section below explains why this happens.

Back to top

4. Why is only one value shown? I have x values in the array?

There can only be one value in each cell. To be able to see all values enter the formula in cell range A1:C1

  1. Select cell range A1:C1
  2. Press with left mouse button on in the formula bar
  3. Press and hold CTRL + SHIFT simultaneously
  4. Press Enter
  5. Release all keys

The animated picture above shows you how to extend an array formula from cell A1 to A1:C1, this allows you to see all values in the array.

excel arrays1

You have now extended the formula to three cells and all values in the array are visible on the sheet, see picture above.

Back to top

5. What are vertical and horizontal arrays?

You can construct arrays with a comma delimiter and a semicolon delimiter.

What is the difference? Use the comma when you want values horizontally and semicolon vertically. Look at the formula bar in this animated picture:

excel arrays

You can also combine colons and semicolons. ={1,2;3,4} A comma tells excel that the next value is to the right of the first value. A semicolon puts the next value on the next row.

excel arrays2

I try to enter an array with text values but it doesn’t work, why? Use double quotes around your values, like this: ={«A»,»B»}

Back to top

6. How to use cell references in array formulas

a cell ref

All arrays presented above contain constants, meaning they don’t change unless you edit them. This formula =A1:A10 contains a cell reference to A1:A10. The values in this formula change if you change a value in cell range A1:A10. Formula =A1:A10 does not contain any constants.

This means that you can use values on your sheet in your array formula. This is extremely useful.

Back to top

7. How to quickly build an array

I want to construct an array from 1 to 1000? I don’t want to enter all these values.
You don’t have to, the ROW function can do that for you. =ROW(1:1000) creates an array from 1 to 1000.

Back to top

8. How to hard code (literal) values in array formulas?

Can I hard code values from 1 to 1000 in a formula without entering them myself? Yes, you can. Type =ROW(1:1000) in the formula bar and press F9.

Excel converts =ROW(1:1000) to ={1,2,3, … , 1000)

Back to top

9. Is Ctrl + Shift + Enter always necessary?

Can I build an array formula without entering it as an array formula?
Yes, you often can. However, it makes the formula more complicated.
Read this post:  No more array formulas?

Excel 365 users enter array formulas as regular formulas, I recommend upgrading to Excel 365. There are so many new things in Excel 365.

Back to top

10. Can I enter an array formula in merged cells?

A beginners guide to Excel array formulas enter array formula in merged cells

Excel tells me «Array formulas are not valid in merged cells», how can I enter array formulas in merged cells?
Yes, you can enter array formulas in merged cells using a workaround: How to enter array formulas in merged cells however, I recommend that you avoid merged cells as much as possible.

Back to top

11. Are there any exceptions?

Yes, both the SUMPRODUCT function and the LOOKUP function lets you build arrays without requiring you to enter them as an array formula.

Recommended articles

Recommended articles

test

The INDEX function lets you encapsulate an array so you don’t need to enter it as an array formula:

Recommended articles

test

Recommended articles

test

Back to top

12. Any caveats using array formulas?

A major disadvantage with array formulas is that if you double press with left mouse button on a cell containing an array formula and then press with left mouse button on another cell, the array formula changes to a regular formula. Beginner Excel users may not know about this and could possibly break your worksheet calculations.

However, this is not the case if you press the Escape key to exit editing an array formula or if you press CTRL + SHIFT + Enter.

Array formulas can slow down your worksheet calculations.

Back to top

13. Alright, show me some useful array formulas?

Recommended articles

test

Recommended articles

test

Recommended articles

test

Repeat values across cells
This article explains how to repeat specific values based on a table, the table contains the items to be repeated […]

Cool, even more complicated calculations?

Recommended articles

test

Recommended articles

test

Dynamic scoreboard
This article demonstrates a scoreboard, displayed to the left, that sorts contestants based on total scores and refreshes instantly each […]

Recommended articles

test

Find numbers closest to sum
Excelxor is such a great website for inspiration, I am really impressed by this post Which numbers add up to […]

Recommended articles

test

Back to top

14. Excel 365 dynamic array formulas

Excel 365 example dynamic array formulas

You can enter array formulas in Excel 365, however, there is no need to do that. Microsoft has now changed how array formulas are entered, they are entered as a regular formula and are now called dynamic array formulas.

Excel 365 shows all values that the array formula returns automatically if the array formula returns more than one value, this behavior is called spilling.

The image above shows a dynamic array formula in cell H3 that returns multiple values and spills those values to cells below. The FILTER function is a new function only available for Excel 365 users.

Back to top

Понравилась статья? Поделить с друзьями:
  • Array excel на русском
  • Array error in excel
  • Arranging windows in word
  • Arranging pictures in word
  • Arrangement of letters in a word