Include Adjacent Blank Cells in SUMIF Range in Google Sheets

Published on

By default, the SUMIF function in Google Sheets ignores blank cells in the criteria range, even if the corresponding sum_range values are filled. But what if you want to treat blank cells in the criteria range as if they hold the value from the cell above?

In this tutorial, you’ll learn how to include adjacent blank cells in a SUMIF range in Google Sheets. We’ll use a dynamic formula that fills blank cells virtually with the value above before performing the conditional sum.

The Problem with SUMIF and Blank Cells

Here’s a typical scenario. Consider the following dataset:

Visual example of including adjacent blank cells in a SUMIF range in Google Sheets

If you try to sum values where the name is “Kim Robinson” using:

=SUMIF(
   A2:A, 
   "Kim Robinson", 
   C2:C
)

You’ll get 4500 because it only includes rows where the name cell explicitly says “Kim Robinson.” The blank rows are skipped—even though they belong to the same person.

The Solution: Fill Blanks on the Fly

To solve this, we virtually fill down the blank cells using a LOOKUP formula inside SUMIF.

Here’s the final formula that includes adjacent blank cells in the SUMIF range:

=SUMIF(
   ARRAYFORMULA(LOOKUP(ROW(A2:A), ROW(A2:A)/(A2:A<>""), A2:A)), 
   "Kim Robinson", 
   C2:C
)

What It Does:

  • LOOKUP(...) fills blank cells in column A with the last non-blank value above.
  • SUMIF(...) then sums values from column C based on these filled-in values.

You can learn more about how this LOOKUP approach works in my tutorial: Fill Blank Cells with Values from the Cell Above in Google Sheets.

Alternatively, you can use this modern SCAN formula to achieve the same result dynamically:

=SUMIF(
   SCAN(, A2:A, LAMBDA(accu, val, IF(val="", accu, val))), 
   "Kim Robinson", 
   C2:C
)

I’ve explained how the SCAN method works in that same tutorial as well.

Example 1: Criteria in a Separate Column

You can also adapt this for a list of names in a separate column (e.g., E2:E5), like so:

=ARRAYFORMULA(
SUMIF(
LOOKUP(ROW(A2:A), ROW(A2:A)/(A2:A<>""), A2:A),
E2:E5,
C2:C
)
)

This version sums the amount column for each unique name in your criteria list, even if the names appear in a range with blanks.

Why This Works

The key is LOOKUP—it dynamically replaces blanks with the last seen non-blank entry, creating a temporary version of the range with no blanks. This lets SUMIF operate as if the data had already been cleaned.

Summary

If your dataset has blank cells in the criteria range and you’d like to treat them as if they repeat the previous value, use LOOKUP with ROW inside SUMIF. This lets you:

  • Avoid manually filling blanks
  • Work with dynamic ranges
  • Get accurate totals without modifying your original data
Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Expert Prashanth KV is a Diamond Product Expert in Google Sheets, officially recognized by Google for his contributions to the Docs Editors Help Community and featured in the Google Product Experts Directory. Explore his blog to learn advanced formulas, automation tips, and problem-solving techniques to elevate your spreadsheet skills.

Top Discussions

More like this

Pivot Table Formatting, Output & Special Behavior in Google Sheets

Pivot Tables in Google Sheets are powerful—but they can get tricky once you move...

Pivot Table Calculations & Advanced Metrics in Google Sheets

When it comes to built-in tools for data analysis and visualization in Google Sheets,...

Google Sheets Pivot Table Tutorial: Basics, Setup, and Date Grouping

The easiest way to summarize, analyze, and report data in Google Sheets is by...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.