Page 422 - Excel 2013 All-in-One For Dummies
P. 422
404 Statistical Functions
The first formula for returning the number of text entries in the sales_table range in cell C14 is
{=SUM(IF(ISTEXT(sales_table),1,0))}
The second formula for returning the number of nontext entries in the sales_ table range in cell C15 is just like the one in cell C17 except that it uses the ISNONTEXT function instead of ISTEXT, as follows:
{=SUM(IF(ISNONTEXT(sales_table),1,0))}
The ISTEXT function in the formula in cell C14 returns logical TRUE when a cell in the sales_table range contains a text entry and FALSE when it does not. The ISNONTEXT function in the formula in cell C15 returns logical TRUE when a cell is blank or contains a numeric entry (in other words, anything but text) and FALSE when it contains text.
In both these formulas, the ISTEXT and ISNONTEXT functions are used as the logical_test arguments of an IF function with 1 as the value_if_true argument and 0 as the value_if_false argument (so that the cells are counted only when the ISTEXT or ISNONTEXT functions return the logical TRUE values). These IF functions are then nested within SUM functions, and these SUM functions, in turn, are entered as array formulas.
Note that you must enter these formulas in the worksheet as array formulas (by pressing Ctrl+Shift+Enter) so that Excel performs its counting calculations on each and every cell in the sales_table cell range. If you just enter the SUM formula with the nested IF and ISTEXT and ISNONTEXT functions as regular formulas, they would return 0 as the count for both text and nontext entries in the sales_table cell range. (See Book III, Chapter 1 for details on building array formulas.)
Counting occupied cells in entire rows, columns, and worksheets
You can use the COUNTA function to count the number of occupied cells in an entire row or column of a worksheet or even an entire worksheet in your workbook. For example, to count all the occupied cells in row 17 of a work- sheet, you enter the following COUNTA formula:
=COUNTA(17:17)
If you want to find the number of nonblank cells in column B of the work- sheet, you enter the following COUNTA formula:
=COUNTA(B:B)