where data is the named range B5:B15. The result is 7, since there are seven cells in B5:B15 that contain numbers greater than zero.

COUNTIF function

The COUNT function counts the number of cells in a range that match supplied criteria. For example, you can use COUNTIF like this: To count positive numbers in this example, we need to use the less than operator (<) with zero like this: The result is 7, since there are seven cells in B5:B15 that contain numbers greater than zero. Cell B9 is not included since it contains zero. Notice that the criteria is enclosed in double quotes ("").  COUNTIF is part of a group of Excel functions that split logical expressions into two parts. As a result, when criteria includes logical operators it must be entered as text surrounded by double quotes (").

Positive including zero

To include zero in the count, use the less than or equal to operator (>=): The result is 8, one more than the formula above since cell B9 is now included in the count.

SUMPRODUCT function

Another way to solve this problem is with the SUMPRODUCT function and Boolean algebra: Working from the inside out, this expression checks if values in data (B5:B15) are greater than zero: Because data contains eleven cells, the result from this expression is an array that contains 11 TRUE and FALSE values: 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 7 as the result. To include zero, adjust the logical test like this: The result is 8, since cell B9 is now included in the count.

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.