fxExcelReps

← How-to guides

How to Sum If a Cell Contains Text in Excel

To add up the amounts where another column contains a word, use SUMIF with asterisks around the word: =SUMIF(A2:A100, "*fuel*", B2:B100). The first range is where to look, the criteria is the word with * on both sides, and the last range holds the amounts.

{"cells": {"A1": "Question", "A10": "Fuel - OMV", "A11": "Rent", "A12": "fuel card fee", "A13": "Parking", "A2": "Spent on fuel", "A3": "Fuel in November", "A4": "Everything but fuel", "A7": "Description", "A8": "Fuel - Shell", "A9": "Groceries", "B1": "Answer", "B10": 92, "B11": 650, "B12": 12, "B13": 30, "B2": "=SUMIF(A8:A13,\"*fuel*\",B8:B13)", "B3": "=SUMIFS(B8:B13,A8:A13,\"*fuel*\",C8:C13,\"Nov\")", "B4": "=SUMIF(A8:A13,\"\u003c\u003e*fuel*\",B8:B13)", "B7": "Amount", "B8": 85, "B9": 120, "C10": "Dec", "C11": "Nov", "C12": "Dec", "C13": "Nov", "C7": "Month", "C8": "Nov", "C9": "Nov"}, "focus": "B2", "note": "Change an amount in column B and watch the totals."}

One condition: SUMIF

The order is range to check, criteria, range to add.

=SUMIF(A2:A100, "*fuel*", B2:B100)All fuel spending.
=SUMIF(A2:A100, "*"&E1&"*", B2:B100)Whatever word is typed in E1.

Two conditions: SUMIFS

In SUMIFS the range to add comes first, then pairs of range and criteria.

=SUMIFS(B2:B100, A2:A100, "*fuel*", C2:C100, "Nov")Fuel in November only.

Everything except

<> means "not equal", and it works with wildcards too.

=SUMIF(A2:A100, "<>*fuel*", B2:B100)All amounts whose description doesn't mention fuel.

Common mistakes

SUMIF returns 0
The word has no asterisks around it, or the amounts are stored as text.
Wrong totals in SUMIFS
The ranges have different sizes, like B2:B100 and A2:A99. Make them start and end on the same rows.

Frequently asked questions

Can SUMIF check part of a cell?

Yes, with wildcards: *word* for anywhere in the cell, word* for the start, *word for the end.

Is SUMIF case-sensitive?

No. fuel, Fuel and FUEL are the same to SUMIF.

How do I count those cells instead?

Use COUNTIF with the same criteria. See count cells that contain text.

Practise it

SUMIFSUMIFSWildcards * and ?

Think you know this?

15 formula tasks, no hints, with a leaderboard. Absolute, relative and mixed references included.

Take the Pro Challenge →

More how-to guides

How to Remove Duplicates in Excel

Three ways to remove duplicates in Excel: the Remove Duplicates button, a UNIQUE formula that updates itself, and a COUNTIF check.

How to Find Duplicates in Excel

Find and flag duplicate values in Excel with COUNTIF, highlight them with conditional formatting, and count how many repeats there are.

How to Extract the First Name in Excel

Get the first name from a full name in Excel with LEFT and FIND, or TEXTBEFORE, including names written as Surname, First name.

How to Extract the Last Name in Excel

Get the last name or the last word from a full name in Excel with TEXTAFTER, or RIGHT, LEN and SUBSTITUTE in older versions.