The result is 9, since nine cells in the range C5:C16 contain values.

COUNTA function

While the COUNT function only counts numbers, the COUNTA function counts both numbers and text. This means you can use COUNTA as a simple way to count cells that are not blank. In the example shown, the formula in F6 uses COUNTA like this: Since there are nine cells in the range C5:C16 that contain values, COUNTA returns 9. COUNTA is fully automatic, so there is nothing to configure.

COUNTIFS function

You can also use the COUNTIFS function to count cells that are not blank like this: The “<>” operator means “not equal to” in Excel, so this formula literally means count cells not equal to nothing. Because COUNTIFS can handle multiple criteria, we can easily extend this formula to count cells that are not empty in Group “A” like this: The first range/criteria pair selects cells that are in Group A only. The second range/criteria pair selects cells that are not empty. The result from COUNTIFS is 4, since there are 4 cells in Group A that are not empty. You can swap the order of the range/criteria pairs with the same result. See also: 50 examples of formula criteria.

SUMPRODUCT function

One problem with COUNTA and COUNTIFS is that they will also count empty strings ("") returned by formulas as not blank, even though these cells are intended to be blank. For example, if A1 contains 21, this formula in B1 will return an empty string: However, COUNTA and COUNTIFS will still count B1 as not empty. If you run into this problem, you can use the SUMPRODUCT function to count cells that are not blank like this:

The expression C5:C16<>"" returns an array that contains 12 TRUE and FALSE values, and the double negative (–) converts the TRUE and FALSE values to 1s and 0s: The result is 9 as before. But this formula will also ignore cells that contain formulas that return empty strings. You can easily extend the logic used in SUMPRODUCT with other functions as needed. For example, the variant below uses the LEN function to count cells that have a length greater than zero: You can extend the formula to count cells that are not blank in Group A like this: This is an example of using Boolean algebra in a formula. The double negative is no longer needed in this case because the math operation of multiplying the two arrays together automatically converts the TRUE and FALSE values to 1s and 0s: The final result is 4, since there are four cells in Group A that are not blank in C5:C16. Note: one reason the Boolean syntax above is useful is because you can drop the same logical expressions into a newer function like the FILTER function to extract cells that meet the same criteria. The SUMPRODUCT function is more versatile than RACON functions like COUNTIFS, SUMIFS, etc. and you will often see it used in formulas that solve tricky problems. You can read more about SUMPRODUCT here. 

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.