Author: Oscar Cronquist Article last updated on September 14, 2022

The COUNTBLANK function counts empty or blank cells in a range.

The picture above demonstrates the COUNTBLANK function entered in cell F3. The evaluated range is C3:C10, two of the cells contains formulas, three cells seem to be empty but only one is in fact empty.

Cell C4 has a formula that returns a blank, note that the COUNTBLANK function considers this cell empty. Cell C7 has a space character and is therefore counted. Only cell C6 is really empty.

Use the TRIM function to remove space characters.

1. COUNTBLANK Function Syntax

COUNTBLANK(value1, [value2], ...)

Back to top

2. COUNTBLANK Function Arguments

value1 Required. A cell reference to a range for which you want to count empty cells.
[value2] Optional. Up to 254 additional arguments like the one above.

The COUNTBLANK function counts errors as not empty.

Back to top

3. COUNTBLANK Function example

The formula in cell F3 counts two empty cells in cell range C3:C10. Note, there is also one error value meaning the COUNTBLANK function works with error values as well.

Formula in cell F3:

=COUNTBLANK(C3:C10)

Explaining formula

COUNTBLANK(C3:C10)

becomes

COUNTBLANK({"A";"";44;0;" ";TRUE;#DIV/0!;"Text"})

and returns 2.

Cell C7 is not empty, it contains a space character. Cell C4 contains a formula, however, the output is nothing. The COUNTBLANK function counts cell C4 as empty.

Back to top

4. Count blanks - arrays and other functions

COUNTBLANK function example

This example shows that you can't use hardcoded arrays in the COUNTBLANK function, a dialog box appears telling you there is a problem with the formula.

Formula in cell C3:

=COUNTBLANK({" ", 3, 4, "A", "", ""})

COUNTBLANK function condition1

You can't use other functions in the COUNTBLANK function, unexpected things may happen.

=COUNTBLANK(IF(B3:B11=E3,C3:C11,"A"))

Back to top

5. Count blanks based on a condition

COUNTBLANK function condition

Formula in cell C3:

=SUM(FILTER(C3:C11,B3:B11=E3)="")

Explaining formula

Step 1 - Check values against a condition

The equal sign lets you compare value to value, you can also compare value to multiple values, and the result is an array.

The equal sign is a logical operator and the result is a boolean value TRUE or FALSE.

B3:B11=E3

becomes

{"Pen"; "Pencil"; "Clip"; "Pen"; "Clip"; "Pencil"; "Pen"; "Clip"; "Clip"}="Clip"

and returns

{FALSE; FALSE; TRUE; FALSE; TRUE; FALSE; FALSE; TRUE; TRUE}.

Step 2 - Filter values based on a condition

The FILTER function extracts values/rows based on a condition or criteria.

Function syntax: FILTER(array, include, [if_empty])

FILTER(C3:C11,B3:B11=E3)

becomes

FILTER(C3:C11,{FALSE; FALSE; TRUE; FALSE; TRUE; FALSE; FALSE; TRUE; TRUE})

becomes

FILTER({"";7;45;31;"";37;98;"";6}, {FALSE; FALSE; TRUE; FALSE; TRUE; FALSE; FALSE; TRUE; TRUE})

and returns

{45; ""; ""; 6}.

Step 3 - Find blank values

FILTER(C3:C11,B3:B11=E3)=""

becomes

{45; ""; ""; 6}=""

and returns

{FALSE; TRUE; TRUE; FALSE}.

Step 5 - Add boolean values

The SUM function allows you to add numerical values, the function returns the sum in the cell it is entered in. The SUM function is cleverly designed to ignore text and boolean values, adding only numbers.

Function syntax: SUM(number1, [number2], ...)

SUM((FILTER(C3:C11,B3:B11=E3)="")*1)

becomes

SUM({FALSE; TRUE; TRUE; FALSE})

and returns 2.

FALSE is 0 (zero) and TRUE is 1.

Back to top

6. Count blanks based on a list

COUNTBLANK function list

Formula in cell C3:

=SUM((FILTER(C3:C11,COUNTIF(E3:E4,B3:B11))="")*1)

Explaining formula

Step 1 -

COUNTIF(E3:E4,B3:B11)

Step 2 -

FILTER(C3:C11,COUNTIF(E3:E4,B3:B11))

Step 3 -

FILTER(C3:C11,COUNTIF(E3:E4,B3:B11))=""

Step 4 -

(FILTER(C3:C11,COUNTIF(E3:E4,B3:B11))="")*1

Step 5 -

SUM((FILTER(C3:C11,COUNTIF(E3:E4,B3:B11))="")*1)

Back to top

7. Count blanks in a delimited text string

COUNTBLANK function string

Formula in cell C3:

=SUM((TEXTSPLIT(C3,";")="")*1)

Explaining formula

Step 1 -

TEXTSPLIT(C3,";")

Step 2 -

TEXTSPLIT(C3,";")=""

Step 3 -

(TEXTSPLIT(C3,";")="")*1

Step 4 -

SUM((TEXTSPLIT(C3,";")="")*1)

Back to top

8. Count blanks in multiple cell ranges

COUNTBLANK function multiple cell ranges

Formula in cell B12:

=SUM((VSTACK(B3:B9,D3:D9,F3:F9)="")*1)

Explaining formula

Step 1 - Join arrays

VSTACK(B3:B9,D3:D9,F3:F9)

Step 2 - Check if empty

VSTACK(B3:B9,D3:D9,F3:F9)=""

Step 3 - Convert boolean values to numbers

(VSTACK(B3:B9,D3:D9,F3:F9)="")*1

Step 4 - Calculate a total

SUM((VSTACK(B3:B9,D3:D9,F3:F9)="")*1)

Back to top