18.11.2014 Views

Microsoft Office

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Introducing Array Formulas 17<br />

Alternatively, you can use the SUMPRODUCT function. The formula that follows is not an array formula, but<br />

it uses two array constants.<br />

=SUMPRODUCT({1,2,3,4},{5,6,7,8})<br />

A formula can work with both an array constant and an array stored in a range. The following formula, for<br />

example, returns the sum of the values in A1:D1, each multiplied by the corresponding element in the array<br />

constant:<br />

=SUM((A1:D1*{1,2,3,4}))<br />

This formula is equivalent to:<br />

=SUM(A1*1,B1*2,C1*3,D1*4)<br />

Array constant elements<br />

An array constant can contain numbers, text, logical values (TRUE or FALSE), and even error values, such<br />

as #N/A. Numbers can be in integer, decimal, or scientific format. You must enclose text in double quotation<br />

marks. You can use different types of values in the same array constant, as in this example:<br />

{1,2,3,TRUE,FALSE,TRUE,”Moe”,”Larry”,”Curly”}<br />

An array constant can’t contain formulas, functions, or other arrays. Numeric values can’t contain dollar<br />

signs, commas, parentheses, or percent signs. For example, the following is an invalid array constant:<br />

{SQRT(32),$56.32,12.5%}<br />

Understanding the Dimensions of an Array<br />

As stated previously, an array can be either one dimensional or two dimensional. A one-dimensional array’s<br />

orientation can be either vertical or horizontal.<br />

One-dimensional horizontal arrays<br />

The elements in a one-dimensional horizontal array are separated by commas. The following example is a<br />

one-dimensional horizontal array constant:<br />

{1,2,3,4,5}<br />

To display this array in a range requires five consecutive cells in a row. To enter this array into a range, select<br />

a range of cells that consists of one row and five columns. Then enter ={1,2,3,4,5} and press<br />

Ctrl+Shift+Enter.<br />

If you enter this array into a horizontal range that consists of more than five cells, the extra<br />

cells will contain #N/A (which denotes unavailable values). If you enter this array into a vertical<br />

range of cells, only the first item (1) will appear in each cell.<br />

NOTE<br />

The following example is another horizontal array; it has seven elements and is made up of text strings:<br />

{“Sun”,”Mon”,”Tue”,”Wed”,”Thu”,”Fri”,”Sat”}<br />

To enter this array, select seven cells in a row and type the following (followed by Ctrl+Shift+Enter):<br />

={“Sun”,”Mon”,”Tue”,”Wed”,”Thu”,”Fri”,”Sat”}<br />

317

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!