Smart Systems for Home

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

Google Sheets SUMIF Contains Text: Complete 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 values in Google Sheets based on whether a cell contains specific text, use the SUMIF function combined with asterisks (*) as wildcards. The basic formula structure is =SUMIF(range, "*text*", sum_range). The asterisks tell Google Sheets to look for the specified text regardless of what characters come before or after it, allowing for a "contains" search rather than an exact match.

What You'll Need

  • A Google account with access to Google Sheets.
  • A dataset containing a column of text (the criteria range) and a column of numbers (the sum range).
  • Basic familiarity with selecting cell ranges in a spreadsheet.

Step-by-Step

  1. Organize Your Data: Ensure your data is structured in columns. For example, Column A should contain your descriptions (e.g., "Office Supplies - Paper", "Office Supplies - Pens", "Travel - Flight") and Column B should contain the corresponding costs (e.g., 20, 10, 500).
  2. Select Your Target Cell: Click on the empty cell where you want the total sum to appear.
  3. Start the Formula: Type =SUMIF( to begin the function.
  4. Define the Criteria Range: Highlight the range of cells that contain the text you want to search. For example, if your descriptions are in cells A2 through A100, your formula should now look like =SUMIF(A2:A100,.
  5. Enter the "Contains" Criteria: To find any cell that contains a specific word, wrap that word in asterisks and double quotes. If you want to sum everything containing the word "Office", type "*Office*". The formula now looks like =SUMIF(A2:A100, "*Office*",.
  6. Define the Sum Range: Highlight the range of cells containing the numbers you want to add up. If your costs are in B2 through B100, type B2:B100.
  7. Close and Execute: Close the parenthesis and press Enter. The final formula is =SUMIF(A2:A100, "*Office*", B2:B100).
  8. Using a Cell Reference (Optional): If you want to be able to change the search term without editing the formula, type the search word in a separate cell (e.g., D1). Use the ampersand (&) to join the wildcards to the cell: =SUMIF(A2:A100, "*"&D1&"*", B2:B100).

Common Mistakes

One of the most frequent errors is forgetting the double quotes around the criteria. In Google Sheets, any text or wildcard used directly inside a formula must be enclosed in quotes; otherwise, the spreadsheet interprets the text as a named range or a function, resulting in a #NAME? error.

Another common mistake is confusing the order of arguments. The SUMIF function always follows the order: Range to check, Criteria to match, Range to sum. If you swap the first and third arguments, the formula will either return 0 or an error because it will try to look for text within a column of numbers.

Users also often forget that SUMIF is not case-sensitive. If you search for "*OFFICE*", it will still sum cells containing "office" or "Office". While this is usually helpful, it can be a mistake if you specifically need to differentiate between case-sensitive terms. In those rare instances, SUMIF cannot be used alone; you would need a combination of SUMPRODUCT and FIND.

Finally, avoid using a range for the sum_range that is a different size than the criteria range. If your criteria range is A2:A100 but your sum range is B2:B50, Google Sheets may produce inaccurate results or unexpected behavior because the ranges are not aligned.

Tips

To perform a "starts with" search instead of a "contains" search, place the asterisk only at the end of the text: "Office*". This will sum "Office Supplies" but ignore "Head Office". Conversely, to perform an "ends with" search, place the asterisk only at the beginning: "*Supplies". This will sum "Office Supplies" and "School Supplies" but ignore "Supplies Warehouse".

If you need to sum values based on multiple text criteria (for example, cells that contain "Office" AND "Paper"), the SUMIF function is insufficient because it only supports one condition. In this case, upgrade to the SUMIFS function. The syntax for SUMIFS is slightly different: the sum_range comes first, followed by pairs of criteria ranges and criteria. Example: =SUMIFS(B2:B100, A2:A100, "*Office*", A2:A100, "*Paper*").

For cleaner spreadsheets, use the cell reference method mentioned in the step-by-step section. By linking your formula to a cell like D1, you can create a dynamic dashboard where you simply type a keyword into D1 to instantly update the total sum without ever touching the complex formula again.

If your data is very large, consider using a Pivot Table. While SUMIF is great for a single total, a Pivot Table can group every unique text string and sum them all simultaneously, saving you from writing dozens of individual SUMIF formulas for different categories.

Troubleshooting

If your formula returns 0 when you know there should be a total, first check for hidden spaces. A cell that looks like it contains "Office" might actually contain " Office " (with leading or trailing spaces). While the wildcard "*Office*" usually handles this, ensure your search term is spelled exactly as it appears in the data.

If you see a #VALUE! error, check that your sum_range contains only numbers. If there are text strings or errors (like #DIV/0!) within the column you are trying to sum, the SUMIF function may fail. You can use the =ISNUMBER() function in a helper column to identify non-numeric cells that might be breaking your formula.

If the formula is summing too many items, check your wildcards. Using "*" by itself will sum every cell that contains any text at all. Ensure your specific keyword is placed between the asterisks.

If you are using a cell reference (e.g., "*"&D1&"*") and it isn't working, ensure that cell D1 does not already contain asterisks. If D1 contains "*Office*" and your formula is "*"&D1&"*", the final criteria becomes "**Office**", which can sometimes confuse the parser depending on the data structure.

Frequently Asked Questions

Can I sum cells that do NOT contain certain text?

Yes. Use the "not equal to" operator (<>) inside the quotes. For example, =SUMIF(A2:A100, "<>*Office*", B2:B100) will sum all values where the text does not contain the word "Office".

Does SUMIF work with numbers as text?

Yes, as long as the criteria is wrapped in quotes. If you are looking for a number stored as text, the wildcard method still works, but it is generally better to ensure your number columns are formatted as "Number" via the Format menu.

What is the difference between SUMIF and SUMIFS for text?

SUMIF is for a single condition (e.g., contains "Office"). SUMIFS is for multiple conditions (e.g., contains "Office" AND is dated in "January"). Note that in SUMIFS, the sum_range is the first argument, whereas in SUMIF, it is the last.

Can I use this to sum based on a partial match of a date?

No. Wildcards only work with text strings. To sum based on a partial date (like all entries in a specific month), you should use the SUMIFS function with a start date and end date range, or use a helper column with the MONTH() function.

Will this work across different sheets?

Yes. You simply need to include the sheet name in the range reference. For example: =SUMIF('Data Sheet'!A2:A100, "*Office*", 'Data Sheet'!B2:B100).