Sub topic 7
Counting filled and empty cells with COUNTA and COUNTBLANK
This chapter assumes you can enter values in cells, select ranges, and start a formula with an equals sign. You should also know that COUNT tallies only numeric cells. Here you will learn two companions of COUNT that answer a different question: how many cells are filled, and how many are empty.
Three counting functions, three questions
Excel has three basic counting functions. Each one looks at the same range but decides differently which cells to include.
| Function | Counts | Typical question |
|---|---|---|
| `COUNT` | Cells that hold numbers (including dates) | How many amounts were entered? |
| `COUNTA` | Every cell that is not empty | How many rows have anything in them? |
| `COUNTBLANK` | Empty cells | How many entries are missing? |
The syntax is the same for all three: the function name, then a range in parentheses.
=COUNT(B2:B6)
=COUNTA(B2:B6)
=COUNTBLANK(B2:B6)A worked example
Suppose B2:B6 holds these entries from a sales sheet:
| Cell | Content |
|---|---|
| B2 | 120 |
| B3 | n/a (text) |
| B4 | (empty) |
| B5 | 95 |
| B6 | 0 |
The three formulas return:
=COUNT(B2:B6)returns 3. The numbers are 120, 95, and 0. The textn/ais skipped.=COUNTA(B2:B6)returns 4. It counts 120,n/a, 95, and 0. Only B4 is empty.=COUNTBLANK(B2:B6)returns 1, for B4.
Notice that the zero in B6 counts as a value in both COUNT and COUNTA. A zero is data, not a blank.
A useful check: the counts add up
Every cell in a range is either empty or not empty. So for any range, the following holds:
=COUNTA(B2:B6)+COUNTBLANK(B2:B6)This equals the total number of cells in the range, which is 5 here. You can use this as a quick test that your ranges are what you think they are. The number of text cells is COUNTA minus COUNT.
Common errors
Cells that look empty but are not
COUNTA counts any cell that contains something, including a formula that returns an empty string, such as ="". It also counts a cell holding a single space. Such a cell looks blank, but COUNTA includes it.
COUNTBLANK is different. It counts truly empty cells and also cells whose formula returns "". A cell holding a space is not counted as blank. So the two functions can disagree about a formula cell that returns "": COUNTA counts it as filled, and COUNTBLANK counts it as blank. In that case, COUNTA plus COUNTBLANK is larger than the number of cells.
Using COUNTA when you meant COUNT
If a column mixes numbers with notes like n/a or TBD, COUNTA overstates how many numbers you have. Choose COUNT when the answer feeds an average. AVERAGE divides by the count of numeric cells, so COUNT matches it.
Counting headers
A range that includes the header row adds one text cell to COUNTA. Start the range at the first data row, for example B2 rather than B1.
Practical use: checking completeness
A common task is reporting how much of a form has been filled in. This formula returns a percentage of non-empty cells:
=COUNTA(B2:B6)/ROWS(B2:B6)Format the result as a percentage. For the sample data it returns 80%. If you prefer to report what is missing, use =COUNTBLANK(B2:B6) directly.
Exercise
A range C2:C11 has 10 cells. Six hold numbers, two hold the text "pending", and two are empty. What do COUNT, COUNTA, and COUNTBLANK return?
Show answer
COUNT returns 6, COUNTA returns 8 (six numbers plus two text cells), and COUNTBLANK returns 2. COUNTA plus COUNTBLANK equals 10, the size of the range.
Exercise
A cell in your range contains the formula ="" and shows nothing. Does COUNTA count it? Does COUNTBLANK?
Show answer
Yes to both. COUNTA counts it because the cell contains a formula. COUNTBLANK counts it because the formula returns an empty string.