🟩 Sheet Formulas

How to Sum If a Cell Contains Specific Text in Google Sheets

Type =SUMIF(A2:A,"*apple*",B2:B) to add up every value in B whose row contains the word "apple" anywhere in column A.

=SUMIF(A2:A,"*apple*",B2:B)

The asterisks are wildcards — *apple* matches the text if it appears anywhere in the cell, not just an exact match.

How it works

SUMIF supports wildcards inside the criterion: * stands for any run of characters and ? for a single character. Wrapping your keyword in asterisks turns an exact match into a contains match. To reference a keyword typed in another cell, join it with asterisks: "*"&D2&"*". For more than one condition, switch to SUMIFS.

Variations

Contains text from another cell

=SUMIF(A2:A,"*"&D2&"*",B2:B)

Matches whatever keyword is typed in D2.

Starts with the text

=SUMIF(A2:A,"apple*",B2:B)

Only the trailing asterisk means "begins with".

Contains text AND meets a second rule

=SUMIFS(B2:B,A2:A,"*apple*",C2:C,">10")

SUMIFS adds more criteria pairs.

Examples

ScenarioFormula
Total sales of any 'Pro' plan=SUMIF(A2:A,"*Pro*",B2:B)
Total for a keyword typed in D2=SUMIF(A2:A,"*"&D2&"*",B2:B)

FAQ

Why does SUMIF ignore my keyword?

Without wildcards SUMIF needs an exact match. Wrap the word in asterisks: "*apple*" to match it anywhere in the cell.

How do I sum if a cell contains one of several words?

Add two SUMIFs: =SUMIF(A2:A,"*apple*",B2:B)+SUMIF(A2:A,"*pear*",B2:B), or use SUMPRODUCT with REGEXMATCH for many words.

Is the match case-sensitive?

No, SUMIF wildcard matching ignores case. Use a REGEXMATCH-based SUMPRODUCT if you need case sensitivity.

Related formulas