To use the SUMIF function with text in Excel, use the formula =SUMIF(range, "text", sum_range). This allows you to tell Excel to look through a specific column for a particular word or phrase and then add up the corresponding numbers in a different column. For example, if you have a list of expenses and want to total only the ones labeled "Travel," SUMIF scans the category column for that specific text and sums the costs associated with it.
What You'll Need
- A computer with Microsoft Excel installed (works in all modern versions including Excel 365, 2021, 2019, and 2016).
- A dataset containing at least one column of text (the criteria) and one column of numbers (the values to be summed).
- Basic knowledge of how to select cells and enter a formula in the formula bar.
Step-by-Step
- Organize Your Data: Ensure your data is arranged in columns. For this guide, imagine Column A contains "Category" (text like "Groceries", "Rent", "Utilities") and Column B contains "Amount" (numbers like 50, 1200, 100).
- Select the Result Cell: Click on the empty cell where you want the total to appear. This is typically below your data or in a separate summary table.
- Start the Formula: Type
=SUMIF(into the cell. This opens the function and prepares Excel to receive three specific pieces of information: the range to search, the criteria to look for, and the range to sum. - Define the Range: Click and drag to select the cells containing the text you want to filter. If your categories are in cells A2 through A10, your formula should now look like
=SUMIF(A2:A10,. Press the comma key to move to the next argument. - Enter the Text Criteria: Now, tell Excel which specific word to look for. You have two options here:
- Hard-coded text: Type the word inside double quotation marks. For example, if you want to sum "Groceries", type
"Groceries". The formula is now=SUMIF(A2:A10, "Groceries",. - Cell reference: Instead of typing the word, click a cell that already contains the word "Groceries" (e.g., cell D2). This makes your sheet dynamic; if you change the text in D2, the sum updates automatically. The formula would look like
=SUMIF(A2:A10, D2,.
- Hard-coded text: Type the word inside double quotation marks. For example, if you want to sum "Groceries", type
- Define the Sum Range: Press the comma key again, then click and drag to select the cells containing the numbers you want to add up. If your amounts are in cells B2 through B10, your formula becomes
=SUMIF(A2:A10, "Groceries", B2:B10). - Finalize and Execute: Press the Enter key. Excel will scan Column A for every instance of "Groceries" and add the corresponding values from Column B.
Common Mistakes
One of the most frequent errors when using SUMIF with text is forgetting the double quotation marks. In Excel formulas, any text string that is not a cell reference must be enclosed in quotes. If you type =SUMIF(A2:A10, Groceries, B2:B10) without quotes, Excel will think "Groceries" is a named range. Since it isn't, the formula will return a #NAME? error.
Another common mistake is a mismatch in range sizes. The range (where you look for the text) and the sum_range (where the numbers are) must be the exact same size. If your first range is A2:A10 (9 cells) but your sum range is B2:B11 (10 cells), Excel may return an incorrect result or an error because the rows do not align perfectly. Always ensure both ranges start and end on the same row numbers.
Users also often struggle with leading or trailing spaces. If a cell contains "Groceries " (with a space at the end) but your formula looks for "Groceries", Excel will treat them as different values and will not include that cell in the sum. This is a "hidden" error because the cell looks correct to the human eye, but the computer sees the extra character.
Tips
To make your SUMIF functions more powerful, use Wildcards. If you want to sum everything that contains a certain word rather than matching it exactly, use the asterisk symbol (*). For example, "*Office*" will sum any cell that contains the word "Office", such as "Office Supplies", "Home Office", or "Office Rent". If you want to sum everything that starts with a specific word, use "Office*".
For better organization, create a summary table. Instead of writing ten different formulas for ten different categories, list your categories in one column (D2:D11) and write one SUMIF formula in E2 that references D2: =SUMIF($A$2:$A$10, D2, $B$2:$B$10). By using absolute references (the dollar signs), you can click and drag the fill handle down to automatically calculate the sums for all other categories in your list without having to rewrite the formula.
If you find yourself needing to sum based on multiple text criteria (for example, summing "Groceries" that were bought in "January"), the SUMIF function cannot do this alone. You will need to upgrade to the SUMIFS function (with an 'S'), which allows for multiple criteria ranges and sum ranges.
Troubleshooting
If your SUMIF formula is returning 0 when you know there should be a total, first check for spelling errors. Excel's SUMIF is not case-sensitive (it treats "GROCERIES" and "groceries" the same), but it is extremely sensitive to spelling and spacing. Use the TRIM function in a helper column to remove any accidental spaces from your text data.
If the formula returns a #VALUE! error, check your sum range. Ensure that the cells in the sum range actually contain numbers. If the numbers are formatted as text (often indicated by a small green triangle in the corner of the cell), Excel cannot add them up. You can fix this by selecting the range, clicking the warning icon, and selecting "Convert to Number".
If the result is simply incorrect, verify that your ranges are locked. If you copied the formula down a column, your ranges might have shifted (e.g., A2:A10 became A3:A11). To prevent this, use absolute references by pressing F4 while selecting the range in the formula bar to add the dollar signs (e.g., $A$2:$A$10).
Frequently Asked Questions
Does SUMIF care about uppercase or lowercase letters?
No, SUMIF is not case-sensitive. Searching for "Apple", "APPLE", or "apple" will all return the same result as long as the spelling is identical.
Can I use SUMIF to sum cells that are NOT a certain text?
Yes. To sum everything except a specific word, use the "not equal to" operator: "<>". For example, =SUMIF(A2:A10, "<>Groceries", B2:B10) will sum every value where the category is not "Groceries".
What happens if the text criteria is empty?
If you reference an empty cell as your criteria, Excel will look for cells that are completely blank in the range and sum their corresponding values.
Can I use a cell reference for the sum range instead of a fixed range?
The sum range must be a range of cells (like B2:B10). You cannot put a single cell there unless that single cell is the only value you wish to sum, though this would defeat the purpose of the function.
How do I sum based on a date using the same text method?
While dates are numbers, you can treat them like text by putting them in quotes, such as "1/1/2023". However, it is more reliable to reference a cell containing the date or use the SUMIFS function for date ranges.