Return to Excel Formulas List

Sum If Blank – Excel & Google Sheets

Download Example Workbook

Download the example workbook

This tutorial will demonstrate how to use the SUMIFS Function to sum data corresponding to blank or empty cells in Excel and Google Sheets.

sum if blank Main Function

Sum if Blank

First, we will demonstrate how to sum rows with blank cells.

The SUMIFS Function sums data that meets certain criteria.

We can use the SUMIFS Function to sum all Scores for Players without names in the example below.

SUMIFS Blank

We use double quotes (“”) to represent a blank cell in Excel. Our example ignores Players A, B, C, and D and sums the scores for unknown Players.

Treating Spaces as Blank Cells – With Helper Column

You need to be careful when interacting with blank cells in Excel. Cells can appear blank to you, but Excel won’t treat them as blank. This can occur if the cell contains spaces, linebreaks, or other invisible characters. This is a common problem when importing data into Excel from other sources.

If we need to treat any cells that only contain spaces the same way as if they were blank, then the formula in the previous example will not work. Notice how the SUMIFS Formula does not consider cell B9 below (”   “) to be blank:

SUMIFS Blank or Spaces Error

To treat a cell containing only spaces as if it were a blank cell, we can add a helper column with the TRIM Function to remove the extra spaces from each cell’s value:

SUMIFS Blank or Spaces

We apply the SUMIFS Function to the helper column, and it now calculates the sum accurately.

SUMIFS Blank or Spaces all

The helper column is easy to create and easy to read, but you might wish to have a single formula to accomplish the task. This is covered in the next section.

Treating Spaces as Blank Cells – Without Helper Column

If a helper column is not appropriate for your needs, then you can use the SUMPRODUCT Function in combination with the LEN and TRIM Functions to sum blank rows.

SUMPRODUCT Blank or Spaces

In this example, we use the SUMPRODUCT Function to perform a complicated “sum if” calculation. Let’s walk through the formula.

This is our final formula:

First, the SUMPRODUCT Function lists the array of values from the two cell ranges:

Then, the TRIM Function removes leading and trailing spaces from Player names:

The LEN Function calculates the lengths of the trimmed Player names:

With the logical test (=0), any trimmed Player names with 0 characters are changed to TRUE:

Next the double dashes (–) convert the TRUE and FALSE values into 1s and 0s:

The SUMPRODUCT Function then multiplies each pair of entries in the arrays to produce an array of Scores only for Player names that are blank or made only from spaces:

Finally, the numbers in the array are summed together:

More details about using Boolean statements and the “–” command in a SUMPRODUCT Function can be found here.

Sum If Blank in Google Sheets

These formulas work exactly the same in Google Sheets as in Excel.

sum-if-blank-Google-Function