Smart Systems for Home

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

Excel SUMIF Partial Text: How to Sum with Wildcards

· 5 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 based on partial text in Excel, use the SUMIF function combined with asterisks (*) as wildcards. The basic formula structure is =SUMIF(range, "*text*", sum_range). The asterisks tell Excel to find any characters before or after the specified text, allowing you to sum all entries that contain a specific word or phrase regardless of where it appears in the cell.

What You'll Need

  • A version of Microsoft Excel (all modern versions including Excel 365, 2021, 2019, and 2016 support this).
  • A dataset containing a column of text (labels, categories, or descriptions) and a corresponding column of numbers to be summed.
  • Basic familiarity with selecting cell ranges in a spreadsheet.

Step-by-Step

  1. Organize Your Data: Ensure your data is in a clean table format. For example, place your product descriptions in Column A (the criteria range) and your sales figures in Column B (the sum range).
  2. Select Your Output Cell: Click on the empty cell where you want the total sum to appear.
  3. Start the Formula: Type =SUMIF( to initiate the function.
  4. Define the Criteria Range: Click and drag to select the cells containing the text you want to search through. For example, if your product names are in cells A2 through A100, your formula will now look like =SUMIF(A2:A100,.
  5. Enter the Partial Text Criteria: This is the most critical step. To find partial text, you must wrap your keyword in double quotation marks and asterisks.
    • To find text containing "Apple" anywhere: type "*Apple*".
    • To find text that starts with "Apple": type "Apple*".
    • To find text that ends with "Apple": type "*Apple".
    Your formula should now look like =SUMIF(A2:A100, "*Apple*",.
  6. Define the Sum Range: Click and drag to select the cells containing the numbers you want to add up. If your sales are in B2 through B100, the formula becomes =SUMIF(A2:A100, "*Apple*", B2:B100).
  7. Complete and Execute: Close the parenthesis ) and press Enter. Excel will now scan Column A for any cell containing the word "Apple" and sum the corresponding values in Column B.

Common Mistakes

One of the most frequent errors is forgetting the double quotation marks. In Excel formulas, any text string (including wildcards) must be enclosed in quotes. If you type =SUMIF(A2:A100, *Apple*, B2:B100) without quotes, Excel will return a #NAME? error because it thinks the asterisk is a mathematical operator or a named range that doesn't exist.

Another common mistake is mismatched range sizes. The criteria range (A2:A100) and the sum range (B2:B100) must be exactly the same size. If you select A2:A100 for the text but B2:B50 for the numbers, Excel may return an inaccurate result or an error because the mapping between the search term and the value is broken.

Users also often confuse the SUMIF function with the SUMIFS function. While SUMIF is perfect for a single partial text criterion, it cannot handle multiple conditions. If you try to add a second criteria range to a SUMIF formula, it will fail. For multiple partial text matches (e.g., "Apple" AND "Red"), you must use SUMIFS, which changes the order of arguments, putting the sum range first.

Tips

Using Cell References for Flexibility: Hard-coding text like "*Apple*" into a formula means you have to edit the formula every time you want to change the search term. Instead, put your keyword in a separate cell (e.g., cell D1) and use the ampersand (&) symbol to concatenate the wildcards. The formula would look like this: =SUMIF(A2:A100, "*" & D1 & "*", B2:B100). Now, whatever you type into cell D1 will automatically update the sum.

Case Sensitivity: It is important to note that SUMIF is not case-sensitive. Searching for "*apple*" will find "Apple", "APPLE", and "aPpLe". If you require a case-sensitive sum, you cannot use SUMIF; you would need to combine the SUMPRODUCT function with the EXACT function, which is a significantly more complex array formula.

Combining with Other Wildcards: While the asterisk (*) represents any number of characters, you can also use the question mark (?) wildcard. A question mark represents exactly one single character. For example, if you search for "*App?e*", it would find "Apple" and "Appke", but not "Appple". This is useful for data with slight spelling variations or specific SKU formats.

Troubleshooting

If your formula returns 0 but you can clearly see the text in your sheet, the first thing to check is for leading or trailing spaces in your data. While the asterisk wildcard usually bypasses this, hidden non-breaking spaces (often found in data imported from the web) can sometimes interfere. Try using the TRIM function on your data column to clean up extra spaces.

If the formula returns a #VALUE! error, check your sum range. This error typically occurs if the cells in your sum range contain text instead of numbers. Ensure that your numbers are not formatted as text; you can check this by looking at the alignment in the cell (numbers usually align right, text aligns left) or by using the ISNUMBER function to verify the data type.

If the formula is summing too many items, check your wildcard placement. If you used "*Apple*", it will sum "Apple", "Pineapple", and "Apple Cider". If you only wanted items that start with Apple, remove the first asterisk: "Apple*".

Frequently Asked Questions

Can I use SUMIF for partial text with multiple different words?

SUMIF only supports one criterion. To sum cells containing "Apple" OR "Orange", you should add two SUMIF formulas together: =SUMIF(range, "*Apple*", sum_range) + SUMIF(range, "*Orange*", sum_range).

Does the wildcard work with numbers?

Wildcards only work with text strings. If you are trying to sum based on a partial number (like all IDs starting with 5), you must first convert those numbers to text or use a different logic, such as the LEFT function within a SUMPRODUCT formula.

What is the difference between "*text*" and "text*"?

The first one ("*text*") finds the word anywhere in the cell. The second one ("text*") only finds cells that begin with that specific text. For example, "*east*" finds "Northeast" and "Southeast", while "East*" only finds "Eastern Region".

Can I use this in Google Sheets?

Yes, the SUMIF function and the asterisk wildcard work identically in Google Sheets as they do in Microsoft Excel.

How do I sum cells that do NOT contain a certain partial text?

You can use the "not equal to" operator (<>) inside the quotes. The formula would be =SUMIF(range, "<>*text*", sum_range). This will sum every value except those where the cell contains the specified text.