Sub topic 9
Counting Non-Empty and Empty Cells with COUNTA and COUNTBLANK
This chapter assumes you can enter formulas in Google Sheets and understand cell addresses such as A2 and ranges such as A2:A6. It also assumes you know that COUNT counts numeric cells only.
COUNTA and COUNTBLANK answer different questions:
COUNTAcounts cells that contain something.COUNTBLANKcounts cells that are empty.
These functions are useful when you need to check whether a list is complete, count submitted responses, or find missing values.
COUNTA: count non-empty cells
The COUNTA function counts every non-empty cell in a range. It counts numbers, text, dates, logical values, and errors.
Suppose column A contains this data:
| Cell | Value |
|---|---|
| A2 | Apples |
| A3 | 12 |
| A4 | *(empty)* |
| A5 | 0 |
| A6 | `=IF(FALSE,"Yes","")` |
Use this formula:
=COUNTA(A2:A6)The result is 4. The function counts Apples, 12, 0, and the formula in A6. A zero is still a value. A formula that returns an empty string can also be treated as non-empty by counting functions because the cell contains a formula.
By comparison:
=COUNT(A2:A6)returns 2, because COUNT counts only the numeric values 12 and 0.
COUNTBLANK: count empty cells
Use COUNTBLANK to count cells with no value:
=COUNTBLANK(A2:A6)For the example above, the result is 1, counting A4.
COUNTBLANK also counts cells whose formula returns an empty string in many normal worksheet situations. Therefore, it is best to distinguish between a physically empty cell and a cell that looks empty because its formula returns "".
Choosing the right counting function
The correct function depends on what the count represents.
| Question | Function | What it counts |
|---|---|---|
| How many cells contain numbers? | `COUNT` | Numeric values |
| How many cells contain anything? | `COUNTA` | Non-empty cells |
| How many cells are empty? | `COUNTBLANK` | Blank-looking or empty cells |
This decision can be modeled as a simple check:
Checking data completeness
You can compare COUNTA with the expected number of records. If a response list should contain 20 entries, this formula checks how many entries are present:
=COUNTA(B2:B21)To count missing entries instead, use:
=COUNTBLANK(B2:B21)If every row should contain a response, the two results should add up to 20, although formulas that return empty strings require careful testing.
You can also combine a count with IF to display a status:
=IF(COUNTBLANK(B2:B21)=0, "Complete", "Missing responses")This formula tests whether the blank count equals zero. It returns Complete only when no cells in the range are blank.
Common errors
A common mistake is using COUNTA when you need to count numeric measurements. Labels such as Unknown or numbers stored as text will increase the COUNTA result.
Another mistake is using COUNTBLANK to find cells containing spaces. A cell containing a space is not empty. To detect spaces or other unwanted text, use data-cleaning methods or conditions such as COUNTIF.
Exercise
A2:A6 contains 12, Apples, a blank cell, 0, and the text " " containing one space. What do COUNT(A2:A6), COUNTA(A2:A6), and COUNTBLANK(A2:A6) return?
Show answer
COUNT returns 2, COUNTA returns 4, and COUNTBLANK returns 1. The numeric cells are 12 and 0. The space is non-empty.