Reason 1 – COUNTA Function Is Not Working for Blanks Returned by Formulas
We have used the IF function in the range D5:D12 to extract numbers greater than 70 and return empty values otherwise.
- The COUNTA formula in cell F5 returns 8, although there are only 5 non-blank cells in the range specified in the formula.
=COUNTA(D5:D12)
- This is because the cells that look empty actually contain empty strings returned by the IF function. The COUNTA function does not consider them empty.
- You can create the following formula using the SUMPRODUCT and LEN functions to overcome this:
=SUMPRODUCT(--(LEN(D5:D12)>0))
- You can also create the following formula using the ROWS and COUNTBLANK functions to get the same results. Replace the ROWS function with the COLUMNS function if the count_range is in a single row instead of in a single column.
=ROWS(D5:D12)-COUNTBLANK(D5:D12)
- If the count_range contains text also, you can use the COUNT and COUNTIF functions to create the following formula for the same results as follows.
=COUNT(D5:D12)+COUNTIF(D5:D12,"*?")
Read More: Dynamic Ranges with OFFSET and COUNTA Functions in Excel
Reason 2 – COUNTA Function Is Not Working for Blanks with Invisible Characters
- The COUNTA formula returns 8, although it seems there are only 6 non-empty cells in the range C5:C12 used in the formula.
- Those empty cells contain hidden spaces.
- Remove the hidden characters from those cells and the COUNTA formula will return the expected result as follows.
Read More: How to Use COUNTA Function with Criteria in Excel
Download the Practice Workbook
Related Articles
- How to Use COUNTA from SUBTOTAL Function in Excel
- Difference Between COUNT and COUNTA Functions in Excel
<< Go Back to Excel COUNTA Function | Excel Functions | Learn Excel
Get FREE Advanced Excel Exercises with Solutions!