11.08.2013 Views

Excel's Formula - sisman

Excel's Formula - sisman

Excel's Formula - sisman

SHOW MORE
SHOW LESS

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

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

Chapter 15: Performing Magic with Array <strong>Formula</strong>s 395<br />

The following array formula (in cell B14) returns the average of the range but excludes the cells<br />

containing 0:<br />

{=AVERAGE(IF(B4:B110,B4:B11))}<br />

This formula creates a new array that consists only of the nonzero values in the range. The<br />

AVERAGE function then uses this new array as its argument.<br />

You also can get the same result with a regular (non-array) formula:<br />

=SUM(B4:B11)/COUNTIF(B4:B11,”0”)<br />

This formula uses the COUNTIF function to count the number of nonzero values in the range. This<br />

value is divided into the sum of the values. This formula does not work if the range contains any<br />

blank cells.<br />

The only reason to use an array formula to calculate an average that excludes zero values<br />

is for compatibility with versions prior to Excel 2007. A simple approach is to use<br />

the AVERAGEIF function in a non-array formula:<br />

=AVERAGEIF(B4:B11,”0”,B4:B11)<br />

Determining whether a particular value appears in a range<br />

To determine whether a particular value appears in a range of cells, you can press Ctrl+F and do<br />

a search of the worksheet. But you can also make this determination by using an array formula.<br />

Figure 15-3 shows a worksheet with a list of names in A5:E24 (named NameList). An array formula<br />

in cell D3 checks the name entered into cell C3 (named TheName). If the name exists in the<br />

list of names, the formula then displays the text Found. Otherwise, it displays Not Found.<br />

The array formula in cell D3 is<br />

{=IF(OR(TheName=NameList),”Found”,”Not Found”)}<br />

This formula compares TheName to each cell in the NameList range. It builds a new array that<br />

consists of logical TRUE or FALSE values. The OR function returns TRUE if any one of the values<br />

in the new array is TRUE. The IF function uses this result to determine which message to display.<br />

A simpler form of this formula follows. This formula displays TRUE if the name is found and<br />

returns FALSE otherwise.<br />

{=OR(TheName=NameList)}

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

Saved successfully!

Ooh no, something went wrong!