# How to sum if a cell contains specific text in Excel

Use SUMIF with wildcards around the text: =SUMIF(range,"*"&text&"*",sum_range).

**Excel:** `=SUMIF(A2:A9,"*"&E1&"*",B2:B9)` (Every current version)

**Google Sheets:** the same formula works.

## Example

Sample data (row 1 is the header):

| A | B | C | D | E |
| --- | --- | --- | --- | --- |
| Expense | Amount |  | Contains | travel |
| Travel - flights | 640 |  | Total |  |
| Office supplies | 85 |  |  |  |
| Travel - hotel | 410 |  |  |  |
| Software license | 1200 |  |  |  |
| Team lunch | 96 |  |  |  |
| Travel - taxi | 58 |  |  |  |
| Client travel gifts | 120 |  |  |  |
| Printer ink | 64 |  |  |  |

Formula in E2: `=SUMIF(A2:A9,"*"&E1&"*",B2:B9)`

Result: $1,228

## How it works

The asterisks are wildcards for "any characters", so `"*"&E1&"*"` matches the word at the start, middle or end of the name. The match ignores case, which is why "Travel" and "travel" both count.

## Other ways

- `=SUMPRODUCT(ISNUMBER(SEARCH(E1,A2:A9))*B2:B9)`: Same result. Swap SEARCH for FIND to make it case-sensitive.

## Common mistakes

- Without the asterisks, SUMIF only adds names that are exactly "travel".
- Wildcards match inside longer words too: "travel" also matches "Client travel gifts" here, and "art" would match "Start". Add spaces or use exact categories when that matters.

## Questions

**How do I sum cells that start with a word?**

Put the asterisk only at the end: `"travel*"`.

**Does SUMIFS support wildcards too?**

Yes. `=SUMIFS(B2:B9,A2:A9,"*"&E1&"*")` gives the same total and lets you add conditions.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-29.

Source: https://spreadsheetpractice.com/formulas/sum-if-cell-contains-text
