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.

Creating Formulas That Count and Sum 14<br />

FIGURE 14.4<br />

This worksheet demonstrates various ways to count characters in a range.<br />

Entire cell contents<br />

To count the number of cells containing the contents of the Text cell (and nothing else), you can use the<br />

COUNTIF function as the following formula demonstrates.<br />

=COUNTIF(Data,Text)<br />

For example, if the Text cell contains the string “Alpha”, the formula returns 2 because two cells in the Data<br />

range contain this text. This formula is not case sensitive, so it counts both “Alpha” (cell A2) and “alpha”<br />

(cell A10). Note, however, that it does not count the cell that contains “Alpha Beta” (cell A8).<br />

The following array formula is similar to the preceding formula, but this one is case sensitive:<br />

{=SUM(IF(EXACT(Data,Text),1))}<br />

Partial cell contents<br />

To count the number of cells that contain a string that includes the contents of the Text cell, use this formula:<br />

=COUNTIF(Data,”*”&Text&”*”)<br />

For example, if the Text cell contains the text “Alpha”, the formula returns 3 because three cells in the Data<br />

range contain the text “alpha” (cells A2, A8, and A10). Note that the comparison is not case sensitive.<br />

If you need a case-sensitive count, you can use the following array formula:<br />

{=SUM(IF(LEN(Data)-LEN(SUBSTITUTE(Data,Text,””))>0,1))}<br />

If the Text cells contain the text “Alpha”, the preceding formula returns 2 because the string appears in two<br />

cells (A2 and A8).<br />

259

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

Saved successfully!

Ooh no, something went wrong!