Sum Values Based on Text in Excel with SUMIF
Question details
Sum numeric values in Excel based on an exact text match or a phrase contained in another cell.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A worksheet has text in one column and numeric values in another, and the user wants to total values for matching rows.
- Observed behavior
- The desired result is a total for rows whose text exactly matches a criterion or contains a specified phrase.
Identify the text range, the corresponding numeric sum range, and the cell containing your search text. Make sure the criteria and sum ranges cover the same number of rows and columns.
Sum values for an exact text match
Use this formula when the text in each criteria cell must match the search text exactly.
Type the exact text to match in cell D1.
Select an empty cell and enter =SUMIF(A2:A17,D1,B2:B17). Excel checks A2:A17 against D1 and sums the corresponding values in B2:B17.
Replace A2:A17, D1, and B2:B17 with the criteria range, search cell, and sum range in your worksheet.

Sum values when text contains a phrase
Use wildcard criteria when the search phrase can appear anywhere in the text.
Sum matching text in WPS Spreadsheets
Use SUMIF in WPS Spreadsheets to total values for exact text or partial phrase matches in your workbook.
- 1. Open your workbook: Open WPS Office, select Spreadsheets, and open your Excel workbook.
- 2. Add the search text: Enter the text you want to match in an empty cell, such as D1.
- 3. Enter SUMIF: Select an empty result cell and enter =SUMIF(A2:A17,D1,B2:B17) for an exact match, adjusting the references to your data.
- 4. Use wildcards for a phrase: For a partial match, enter =SUMIF(A2:A17,"*"&D1&"*",B2:B17) in the result cell instead.

Frequently Asked Questions
How do I sum rows that contain a word anywhere in a cell?
Place the word in D1 and enter =SUMIF(A2:A17,"*"&D1&"*",B2:B17). The asterisks match any text before or after the word.
Does SUMIF distinguish between uppercase and lowercase text?
No. SUMIF text criteria are not case-sensitive, so entries such as "Apple" and "apple" match the same criterion.
Why is my SUMIF total missing some values?
Check that the criteria and sum ranges align, such as A2:A17 and B2:B17, and that the values in the sum range are numeric rather than numbers stored as text.
How can I match a literal asterisk or question mark?
In a SUMIF criterion, place a tilde before the character: ~* matches a literal asterisk and ~? matches a literal question mark.




