Welcome to Bo's Excel Array Formula Set Page


MsOffice Index 2 | Microsoft PowerPoint 97 | Microsoft Bug of the Month

If you have some experience using formulas in Microsoft Excel, you know that you can perform some fairly sophisticated operations. For example, you can calculate the total cost of a loan over any given number of years. However, if you really want to master formulas in Excel, you need to know how to use array formulas. You can use array formulas to do the seemingly impossible, such as:

... and more. This column introduces array formulas and explains how to enter, edit, and troubleshoot them.

Note   You may see array formulas referred to as "CSE formulas," because you press CTRL+SHIFT+ENTER to enter them into your workbooks. The only difference is the name.

A quick introduction to arrays and array formulas

If you've done even a little programming, you've probably run across the term array. For our purposes, an array is just a collection of items. In Excel, those items can reside in a single row (called a one-dimensional horizontal array), a column (a one-dimensional vertical array), or multiple rows and columns (a two-dimensional array).

An array formula is a formula that can perform multiple calculations on one or more of the items in an array. Array formulas can return either multiple results or a single result. For example, you can place an array formula in a range of cells and calculate a column or row of subtotals. You can also place a formula in a single cell and calculate a single amount. An array formula that resides in multiple cells is called (logically enough) a multi-cell formula, and an array formula that resides in a single cell is called a single-cell formula. Finally, you can't create three-dimensional arrays or array formulas in Excel. 

The examples in the next section show you how to create multi-cell and single-cell array formulas. 

Try it!

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.

To create a multi-cell array formula 
  1. Start Excel and open a new, blank workbook.
  2. Copy this table and then paste it into the new workbook starting at cell A1. Use the Paste Options button The Paste Options button to match the destination formatting.
    Sales Person Car Type Number Sold Unit Price Total Sales
    Barnhill Guzzler 5 2200  
      Belcher 4 1800  
    Ingle Guzzler 6 2300  
      Belcher 8 1700  
    Jordan Guzzler 3 2000  
      Belcher 1 1600  
    Pike Guzzler 9 2150  
      Belcher 5 1950  
    Sanchez Guzzler 6 2250  
      Belcher 8 2000  

    Note: If you paste this into your Excel Workbook

    Total Sales


    and find that the cells are only showing the formula, then there is a chance that you copied some of the code for this webpage into your Excel worksheet.

    If total sales looks like this              

    Then you need to highlight the cells E2 to E11 then click
             Edit | Clear

    Or, right click and select
    Clear Contents from the right click context menu options and then paste the formulae into the formula bar and use Shift+Ctrl+Enter key combinations. Once this is done, the formulae will  work as described.

  3. Select cells E2 through E11, and then enter the following formula in the formula bar:



Excel surrounds the formula with braces ({}) and places 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 sales person.

Worksheet with first array formula

To create a single-cell array formula
  1. In cell A13 of the workbook, type Total Sales.
  2. In cell B13, enter the following formula, and then press CTRL+SHIFT+ENTER:


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 $111,800 in sales. Do you see how powerful this type of formula can be? For example, say you have 15,000 rows of data. You can sum part or all of that data with a single formula in a single cell.

Also, notice that the single-cell formula is completely independent of the multi-cell formula. This points to another advantage of using array formulas - flexibility. You can take any number of actions, such as changing the formulas in column E or deleting that column altogether, without affecting the single-cell formula.

Array formulas also offer these advantages:

A look at array formula syntax

For the most part, array formulas use standard formula syntax. They all begin with an equal sign, and you can use any of the built-in functions of Excel in your array formulas. The key difference is the need to press CTRL+SHIFT+ENTER to enter your formulas. This is a must. Excel surrounds your array formula with braces — and you cannot type the braces manually.

The next thing you need to understand is that array functions are a form of shorthand. For example, the multi-cell function that you used earlier is the equivalent of:


and so on. The single-cell formula condenses all of those multiplication operations, plus the arithmetic required to add those subtotals: =E2+E3+E4, and so on.

Rules for entering and changing array formulas

We've already harped on the primary rule, but we're doing it again: Press CTRL+SHIFT+ENTER whenever you need to enter or edit an array formula. That rule applies to both single-cell and multi-cell formulas.

Whenever you work with multi-cell formulas, you also need to follow these rules:

Making changes to an array formula

At times, you may need to expand or shrink an array formula.

To expand or shrink an array formula
  1. Go to the sample workbook and clear any single-cell formulas located below the main table.
  2. Paste these additional lines of data into the workbook starting at cell A12. Use the Paste Options button to match the destination formatting.

    Teal Guzzler 6 2500
      Belcher 7 1900
    Wang Guzzler 4 2200
      Belcher 3 2000
    Young Guzzler 8 2300
      Belcher 8 2100


  3. Select the range of cells that contains the current array formula (E2:E11). Or, select any cell within the array formula range, and then press CTRL+/ (the Excel shortcut to select the current array).
  4. Press F2 to start edit mode.
  5. Press CTRL+ENTER (not CTRL+SHIFT+ENTER). Excel places an identical non-array formula in the selected cells.
  6. Expand the selection in column E to include the new rows that you entered in step 2.
  7. Press CTRL+SHIFT+ENTER. Excel places an instance of the formula in the new cells.

    The workbook with an expanded formula

Disadvantages of using array formulas

Array formulas can work what seems like magic, but they also have some disadvantages: