The result is 8, since there are eight cells in the range B5:B15 that contain numeric values.
COUNT function
The COUNT function counts the number of cells in a range that contain numeric values. In this example, we simply need to give COUNT the range B5:B15: The COUNT function is fully automatic, so there is nothing to configure. The result is 8, since there are eight cells in the range B5:B15 that contain numeric values. Cell B9 is not included because it is empty. Cells B11 and B12 are not included because they contain text values. Note: the COUNTA function counts numbers and text, but does not count empty cells.
SUMPRODUCT function
Another way to solve this problem is with the SUMPRODUCT function and Boolean algebra: Working from the inside out, the ISNUMBER function is used to test the values in B5:B15: Because the range B5:B15 contains 11 values, the result is an array that contains 11 TRUE and FALSE values: The TRUE values correspond to cells that contain numbers, and the FALSE values represent cells that do not contain numbers. To convert the TRUE and FALSE values to 1s and 0s, we use a double negative (–): The resulting array inside the SUMPRODUCT function looks like this: With a single array to process, SUMPRODUCT sums the array and returns 8 as the result. Note: you might wonder why you should go to the trouble of using SUMPRODUCT and Boolean logic, when the COUNT function will do the job? The main reason is flexibility and extensibility. SUMPRODUCT can easily perform calculations that the COUNT function, or even COUNTIF or COUNTIFS simply can’t perform. One example is the formula below, which adds the NOT function to reverse behavior. Another basic example is this formula, which uses the ISODD function to count odd numbers.
Count cells that do not contain numbers
To count the number of cells in a range that do not contain numbers, you can modify the SUMPRODUCT formula above to use the NOT function like this: The NOT function reverses the output from ISNUMBER, and the final array inside SUMPRODUCT looks like this: The result is 3, since there are three cells in B5:B15 that do not contain numbers.
Dave Bruns
Hi - I’m Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.