Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Excel SUMIF with Text: Step-by-Step Guide

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To sum numbers based on a text condition in Excel, use the SUMIF function with the text criterion in quotes. The basic syntax is =SUMIF(range, "text", sum_range), where range is the column you want to check for the text, "text" is the condition (e.g., "North" or "*apple*"), and sum_range is the column of numbers to add up. For example, =SUMIF(A2:A10, "North", B2:B10) adds all values in B2:B10 where the corresponding cell in A2:A10 equals "North". This works in all modern versions of Excel, including Microsoft 365, Excel 2019, 2021, and Excel for the web. The steps below show how to build the formula, handle partial matches with wildcards, and avoid common errors.

What You'll Need

  • Excel 2016 or later (including Microsoft 365) on Windows or Mac, or Excel for the web. The SUMIF function is not available in Excel 2007 or earlier.
  • A worksheet with at least one column of text labels and one column of numbers to sum. For example, a column of region names and a column of sales amounts.
  • Basic familiarity with selecting cell ranges and typing formulas.

Step-by-Step

  1. Identify your ranges. Decide which column contains the text you want to test (the range) and which column contains the numbers to add (the sum_range). They can be the same column if you are summing numbers that also contain text, but usually they are different. For example, if column A has product names and column B has quantities, your range is A2:A100 and your sum_range is B2:B100.
  2. Click the cell where you want the result. This is where the total will appear. Choose an empty cell below or beside your data.
  3. Type the SUMIF formula. Start with =SUMIF(. Then enter the range, a comma, the criterion in double quotes, a comma, and the sum_range. For example: =SUMIF(A2:A100, "Widget", B2:B100). Press Enter. The cell will show the sum of all values in B2:B100 where the corresponding cell in A2:A100 is exactly "Widget".
  4. Use a cell reference for the criterion (optional). If you want to change the text condition without editing the formula, put the text in a separate cell (e.g., D1) and refer to it: =SUMIF(A2:A100, D1, B2:B100). This is handy for building a small summary table. Note that the text in D1 must match exactly (unless you use wildcards, see next step).
  5. Add wildcards for partial matches. To sum values where the text contains a certain word, use asterisks. For example, =SUMIF(A2:A100, "*Widget*", B2:B100) sums all rows where the text in column A contains "Widget" anywhere. Use a question mark (?) to match exactly one character. To find text that starts with "Widget", use "Widget*"; to find text that ends with "Widget", use "*Widget". Wildcards work with text, not with numbers.
  6. Handle case sensitivity. SUMIF is not case-sensitive: "widget" and "Widget" are treated the same. If you need a case-sensitive sum, use SUMPRODUCT with EXACT, but that is beyond this guide. For most purposes, SUMIF's default behavior is fine.
  7. Copy the formula down or across if needed. If you are building a summary table with multiple text criteria, you can copy the formula and adjust the cell references. Use absolute references (e.g., $A$2:$A$100) for the ranges if you plan to copy the formula to other cells, so the ranges do not shift.
  8. Check the result. Verify a few rows manually: filter the text column for your criterion and sum the visible numbers in the sum_range. Compare with your formula result. If they differ, see Troubleshooting.

Common Mistakes

  • Forgetting quotes around text criteria. A formula like =SUMIF(A2:A10, North, B2:B10) will cause a #NAME? error because Excel thinks North is a named range. Always enclose literal text in double quotes.
  • Mismatched range sizes. The range and sum_range must be the same size and shape. If range is A2:A10 (9 cells) and sum_range is B2:B11 (10 cells), Excel may return incorrect results or an error. Always use equal-sized ranges.
  • Including the header row. If your range includes the header (e.g., A1:A100 where A1 is "Product"), the header text might accidentally match your criterion if it contains the same word, or it might not matter, but it is safer to start from the first data row (A2).
  • Using wildcards with numbers. Wildcards only work on text. If your range contains numbers stored as text, wildcards may not behave as expected. Ensure your data is consistent.
  • Expecting SUMIF to work with multiple criteria. SUMIF handles only one condition. For multiple text conditions, use SUMIFS (which supports multiple ranges and criteria).
  • Typing the criterion without wildcards when you need partial match. "Widget" matches only cells that are exactly "Widget". To match "Widget Pro" or "Super Widget", use "*Widget*" or similar.

Tips

  • Use cell references for criteria to make your formulas dynamic. For example, if you have a list of product names in D2:D5, you can put =SUMIF($A$2:$A$100, D2, $B$2:$B$100) in E2 and copy down. This creates a quick summary table.
  • Combine SUMIF with wildcards for flexible reporting. For instance, sum all sales for products containing "Pro" with =SUMIF(A2:A100, "*Pro*", B2:B100).
  • Use the Formula Bar to edit. Click the cell, then edit in the formula bar to see the whole formula and avoid mistakes.
  • Test with a small range first. Before applying to a large dataset, try the formula on a few rows to confirm it works as expected.
  • Remember that SUMIF ignores text in the sum_range. If the sum_range contains text, those cells are ignored, which is usually what you want.

Troubleshooting

If your SUMIF formula returns 0 or an unexpected result, check these common issues:

  • Result is 0: The text criterion might not match exactly. Check for extra spaces (use TRIM on the range or criterion), case differences (SUMIF is case-insensitive, so that is rarely the issue), or hidden characters. Also verify that the sum_range contains numbers, not text that looks like numbers.
  • #NAME? error: You likely forgot to put quotes around the text criterion. Enclose it in double quotes.
  • #VALUE! error: The range or sum_range might contain errors, or the ranges are not the same size. Check for #N/A or other errors in the data.
  • Formula returns wrong total: Ensure the range and sum_range are aligned. If you copy the formula, use absolute references ($A$2:$A$100) to prevent shifting.
  • Wildcards not working: Confirm that the cell format is text, not a number. Also, wildcards are not supported in some older Excel versions or in Excel for the web? Actually, Excel for the web supports wildcards in SUMIF. If wildcards do not work, check that you are using the asterisk (*) and not a different character.
  • If that did not work: Try breaking the problem down: use COUNTIF with the same criteria to see how many matches Excel finds. If COUNTIF returns 0, the issue is with the criterion or range. If it returns a number, the issue is with the sum_range. Also, ensure calculation is set to automatic (Formulas > Calculation Options > Automatic).

Frequently Asked Questions

Can SUMIF handle multiple text criteria?

No, SUMIF accepts only one condition. Use SUMIFS instead, which allows multiple range/criteria pairs. For example, =SUMIFS(B2:B100, A2:A100, "North", C2:C100, "Widget").

Is SUMIF case-sensitive?

No, SUMIF treats "apple" and "Apple" as the same. For case-sensitive summing, use SUMPRODUCT with EXACT, but that is more complex.

How do I sum cells that contain specific text anywhere in the cell?

Use wildcards: =SUMIF(A2:A100, "*text*", B2:B100). The asterisks match any number of characters before and after "text".

Why does my SUMIF return 0 even though I see matching text?

Check for leading or trailing spaces in the text cells. You can use =SUMIF(A2:A100, TRIM("text"), B2:B100) if the criterion has spaces, but the range cells might also have spaces; consider cleaning the data with TRIM. Also, verify that the sum_range actually contains numbers.

Can I use SUMIF with a cell reference that contains wildcards?

Yes, if the cell contains a text string with asterisks, SUMIF will interpret them as wildcards. For example, if D1 contains "*Widget*", then =SUMIF(A2:A100, D1, B2:B100) works as a wildcard search.

Does SUMIF work in Excel for the web?

Yes, SUMIF is fully supported in Excel for the web, including wildcards. The behavior is the same as desktop Excel.