← All how-to recipes

How to SUMIF with a wildcard (sum rows that start with / contain text)

✓ Verified in LibreOffice 25.8.7.3 ✓ Verified in Google Sheets (2026-08-30)

Total the numbers whose label matches a pattern, e.g. every category starting with 'North'.

The formula

AppFormulaNotes
Excel=SUMIF(A2:A6,"North*",B2:B6)* = any characters; ? = one character. Use *text* for 'contains'.
Google Sheets=SUMIF(A2:A6,"North*",B2:B6)Identical wildcard rules.
LibreOffice Calc=SUMIF(A2:A6,"North*",B2:B6)Works when Tools>Options>Calc>Calculate has wildcards enabled (default for xlsx).

How it works

The asterisk wildcard matches any trailing text, so 'North*' catches 'North East', 'North West' and 'Northland' (10+7+2 = 19) but not 'South' or 'East'. Use '*North*' to match North anywhere in the text.

Verified, not just documented

We ran =SUMIF(A2:A6,"North*",B2:B6) in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned 19 — exactly the expected result. We then ran the same formulas in Google Sheets, executed 2026-08-30: a formula-only workbook goes into Google Drive, which converts it to a Sheet and recalculates every formula with Google’s own engine, and comes back out as .xlsx carrying the values Google computed. It returned 19 for the worked example, the same value LibreOffice produced. Both engines’ numbers on this page are executed results. The Excel formula follows Microsoft’s official documented syntax — we do not run Excel.

Functions used

SUMIF — see full Excel, Google Sheets & LibreOffice compatibility for each.

Related recipes

Related comparisons