ExcelReady
CourseMock testsFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before day one. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Mock tests
  • Function guides
  • Blog

Test prep

  • Excel level test
  • Excel test practice
  • Free screening quiz
  • Certificate

Company

  • About
  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Conditional math
  3. SUMIF Contains Text: Sum by Partial Match

SUMIF Contains Text: Sum by Partial Match

By ExcelReady Team·Updated November 1, 2026·6 min read

The short answer

To add up rows whose text contains a word, wrap the word in asterisks: =SUMIF(A2:A8,"hotel",B2:B8). The * wildcard means any characters, so the formula adds "Hotel London" and "Hotel Paris". Use ""&D1&"" for a word in a cell, "<>hotel" to exclude it, and SUMIFS when the text must contain two words.

Key takeaways

  • Asterisks around a word mean contains: "hotel". Use "hotel*" for starts with and "*hotel" for ends with.
  • Join the asterisks to a cell with &: ""&D1&"".
  • "<>hotel" adds every row that does not contain the word.
  • SUMIF ignores capitals; use SUMPRODUCT with FIND when case matters.
  • Check for overlap before adding two contains totals, or a row can be counted twice.
On this page+
  1. Why an exact SUMIF returns 0 for partial text
  2. How to sum if a cell contains text
  3. How to use a word from a cell
  4. How to sum if a cell contains two words
  5. Case-sensitive totals with FIND
  6. Why SUMIF contains text returns the wrong total
  7. How to build a spending summary by keyword
  8. Practise it

SUMIF contains text adds the numbers for every row where a word appears anywhere in a cell, not only where the cell matches it exactly. You do it with the asterisk wildcard: =SUMIF(A2:A8,"*hotel*",B2:B8). This is the go-to formula for messy descriptions, such as expense lines or product names, where the word you care about sits inside longer text.

Why an exact SUMIF returns 0 for partial text#

A plain text criteria must match the whole cell. Here is a short expense list in A1:B8:

AB
1DescriptionAmount
2Taxi to airport45
3Hotel London320
4Taxi to client28
5Train ticket64
6Hotel Paris280
7Airport parking36
8Team lunch90

=SUMIF(A2:A8,"hotel",B2:B8) returns 0, because no cell is exactly "hotel". Both hotel lines have a city after the word. To match part of the text, you need a wildcard. The basics of SUMIF are in how to use SUMIF.

How to sum if a cell contains text#

Put an asterisk (*) on each side of the word. In a criteria, * means "any number of characters, including none":

Excel formula
=SUMIF(A2:A8,"*hotel*",B2:B8)

The result is 600: 320 for Hotel London plus 280 for Hotel Paris. SUMIF checks column A for the pattern and adds the matching amounts from column B. It ignores capitals, so "hotel" matches "Hotel".

Here are more totals from the same list:

QuestionFormulaResult
Contains taxi=SUMIF(A2:A8,"*taxi*",B2:B8)73
Contains airport=SUMIF(A2:A8,"*airport*",B2:B8)81
Starts with hotel=SUMIF(A2:A8,"hotel*",B2:B8)600
Ends with ticket=SUMIF(A2:A8,"*ticket",B2:B8)64
Doesn't contain hotel=SUMIF(A2:A8,"<>*hotel*",B2:B8)263

"Contains airport" adds Taxi to airport (45) and Airport parking (36), because the word can sit at the start or the end. The <> in front of a pattern means "not", so the last row adds everything except the two hotels: 863 - 600 = 263.

There is also the ? wildcard, which stands for exactly one character. The guide to wildcards in COUNTIF and SUMIF covers both.

How to use a word from a cell#

To change the word without editing the formula, type it in a cell and join the asterisks to it with &. With taxi in D1:

Excel formula
=SUMIF(A2:A8,"*"&D1&"*",B2:B8)

The result is 73 (45 + 28). Excel builds the text "*taxi*" and then adds. Type hotel in D1 instead and the total becomes 600.

Keep the asterisks inside quotes and the cell outside them. Writing "*D1*" looks for the letters D1 and returns 0. This setup is ideal for a small summary: list your keywords down column D, put the formula next to the first with the ranges locked ($A$2:$A$8 and $B$2:$B$8), and fill down (Windows: Ctrl+D; Mac: ⌘D).

How to sum if a cell contains two words#

When a row must contain both words, use SUMIFS with the text range twice:

Excel formula
=SUMIFS(B2:B8,A2:A8,"*taxi*",A2:A8,"*airport*")

The result is 45: only "Taxi to airport" contains both words. SUMIFS puts the sum range first and adds a row only when every condition is TRUE. The comparison of SUMIF vs SUMIFS explains the argument order.

For either word (OR logic), add two SUMIFs, but watch for overlap. =SUMIF(A2:A8,"*taxi*",B2:B8)+SUMIF(A2:A8,"*airport*",B2:B8) gives 73 + 81 = 154, yet the real spend on taxi or airport lines is only 109 (45 + 28 + 36). "Taxi to airport" was added twice, once for each word. Adding two SUMIFs only works when no row contains both words.

Case-sensitive totals with FIND#

SUMIF never cares about capitals. If case matters, for example a code "PRO" that must not match "pro", use SUMPRODUCT with FIND, which respects capitals:

Excel formula
=SUMPRODUCT(ISNUMBER(FIND("Hotel",A2:A8))*B2:B8)

FIND returns a position when it finds "Hotel" and an error when it doesn't. ISNUMBER turns that into TRUE or FALSE, and multiplying by the amounts keeps only the matching rows. Here the result is still 600, because both hotel lines use a capital H.

Why SUMIF contains text returns the wrong total#

If the total is 0 or looks off, check these:

  1. No asterisks. "hotel" only matches cells that are exactly "hotel". Use "*hotel*".
  2. The cell reference is inside the quotes. Write "*"&D1&"*".
  3. A word inside another word. "*cat*" also matches "Catering" and "Location". Add spaces to the pattern, like "* cat *", or check the matches with a COUNTIF first.
  4. Misaligned ranges. The text range and the sum range should start on the same row and be the same size.
  5. Amounts stored as text. SUMIF skips numbers stored as text. Convert them with VALUE.

To count the matching rows instead of adding them, use COUNTIF contains text. To leave out one exact value rather than a pattern, see SUMIF not equal to, and for totals above a number, read SUMIF greater than.

How to build a spending summary by keyword#

Keyword totals are most useful side by side. List your keywords in D2:D4 (taxi, hotel, train), type this in E2 and fill down:

Excel formula
=SUMIF($A$2:$A$8,"*"&D2&"*",$B$2:$B$8)
KeywordTotal
taxi73
hotel600
train64

The three totals add up to 737, while the whole Amount column is 863. The gap of 126 is Airport parking (36) and Team lunch (90): the lines no keyword matched. Checking the gap like this shows which rows your keywords miss, and it also warns you when a row matched two keywords and was added twice.

Practise it#

Wildcards turn a strict SUMIF into a flexible one, and they are a favourite in data-cleaning test tasks. Practise wildcards in criteria in a live spreadsheet, then practise SUMIF to lock in the argument order. Each lesson checks your formula instantly. The SUMIF function guide is there when you need the syntax.

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

What was spent on hotels? In E2, use SUMIF to add the Amount (B2:B8) for every expense whose description in A2:A8 contains hotel.

fx
ABCDEF
1
Description
Amount
2
Taxi to airport
45
Hotels
3
Hotel London
320
4
Taxi to client
28
5
Train ticket
64
6
Hotel Paris
280
7
Airport parking
36
8
Team lunch
90
9
10
11

Tip: The criteria is the word hotel with an asterisk on each side, in quotes. The amounts to add go last.

Practise this in a lesson

LessonWildcards and cell-based criteriaMatch partial text with * and ?, and build criteria from cells like ">"&H5 so your formulas adapt.LessonSUMIFAdd up only the numbers that meet a condition, with and without a separate sum range.Function guideSUMIFAdd up values that meet one condition with SUMIF. Totals by category, person or amount, the argument-order trap, and a live exercise.

Frequently asked questions

How do I sum cells that contain specific text in Excel?

+

Use SUMIF with asterisks around the text: =SUMIF(A2:A8,"taxi",B2:B8). It adds the numbers in B2:B8 for every row where column A contains taxi anywhere.

How do I use SUMIF contains with a cell reference?

+

Join the asterisks to the cell with ampersands: =SUMIF(A2:A8,""&D1&"",B2:B8). Type the word in D1 and the total updates.

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

+

Add two SUMIFs: =SUMIF(A2:A8,"taxi",B2:B8)+SUMIF(A2:A8,"train",B2:B8). This is correct only if no row contains both words, otherwise that row is added twice.

How do I sum if a cell contains two words?

+

Use SUMIFS with the same text range twice: =SUMIFS(B2:B8,A2:A8,"taxi",A2:A8,"airport"). A row is added only when it contains both words.

Is SUMIF with wildcards case-sensitive?

+

No. "hotel" matches Hotel, hotel and HOTEL. For a case-sensitive total, use =SUMPRODUCT(ISNUMBER(FIND("Hotel",A2:A8))*B2:B8).

Sources

  • SUMIF function - Microsoft Support
  • SUMIFS function - Microsoft Support
  • SUMPRODUCT function - Microsoft Support

Written and checked by the ExcelReady Team. First published November 1, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. Why an exact SUMIF returns 0 for partial text
  2. How to sum if a cell contains text
  3. How to use a word from a cell
  4. How to sum if a cell contains two words
  5. Case-sensitive totals with FIND
  6. Why SUMIF contains text returns the wrong total
  7. How to build a spending summary by keyword
  8. Practise it

Keep reading

Conditional math· 6 min read

COUNTIF Contains Text: Count Partial Matches

To count cells that contain a word anywhere in the text, put asterisks around it: =COUNTIF(A2:A8,"*blue*"). The * wildcard stands for any number of characters, so the formula counts "Blue Jeans", "Navy Blue Jacket" and "Light blue Cap". For a word in a cell, use "*"&E1&"*". COUNTIF ignores capitals.

Conditional math· 7 min read

How to Use SUMIF in Excel

SUMIF adds up the numbers in the rows that meet one condition. Write =SUMIF(range, criteria, sum_range): the cells to check, what they must match, then the numbers to add. For example, =SUMIF(C2:C9,"Travel",D2:D9) totals all Travel claims. Leave out sum_range when the condition is about the numbers themselves.

Conditional math· 6 min read

SUMIF Greater Than or Less Than a Number

To add values greater than a number, put the operator and the number in quotes: =SUMIF(B2:B8,">500"). With two arguments, SUMIF adds the same cells it checks. To check one column and add another, give a third argument: =SUMIF(C2:C8,">=10",B2:B8). Use "<", ">=" or "<=" for the other comparisons, and ">"&E1 for a limit in a cell.

More on conditional math

  • SUMIF Not Equal To: Exclude a Value From a Total
  • SUMIFS With OR Logic in Excel
  • Excel Wildcards: *, ? and ~ in COUNTIF and SUMIF
  • AVERAGEIF and AVERAGEIFS in Excel
  • AVERAGEIFS in Excel: Averages With Several Conditions
  • How to Count Cells With Text in Excel
All conditional math articles →

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback, right in your browser. Nothing to download.

Start learning for free