SUMIF with Text in Excel: Step-by-Step Guide
In this article
SUMIF with text lets you add numbers in one column only when a text condition in another column is met—for example, summing all invoice amounts where the client name is "Acme" or all hours logged on a project tagged "Design". The function is built into every modern version of Excel (2016 and later, Microsoft 365, Excel for Mac, and Excel for the web), so nothing needs to be installed. The only requirement is that your data is arranged in columns with a clear header row, and that the text you are matching is spelled consistently.
What You'll Need
- Excel 2016 or later, Microsoft 365, Excel for Mac, or Excel for the web. The steps below use the standard SUMIF syntax, which is the same across these versions.
- A worksheet with at least two columns: one containing text labels (the criteria range) and one containing numbers (the sum range).
- Consistent spelling and spacing in the text column—extra spaces or mixed case can cause matches to fail.
Step-by-Step
- Lay out your data with headers. Put the text labels in one column (for example, column A for client names) and the numbers to add in another (column B for invoice amounts). Include a header row so you can use whole-column references safely. For example: A1 = "Client", B1 = "Amount", A2 = "Acme", B2 = 500, A3 = "Beta", B3 = 300, A4 = "Acme", B4 = 200.
- Choose an empty cell for the result. Click a cell outside your data range, such as D2, and type an equals sign to start the formula.
- Enter the SUMIF function name and open parenthesis. Type
=SUMIF(. Excel will show a tooltip with the three arguments: range, criteria, sum_range. - Select the criteria range. This is the column of text you want to check. Click and drag over A2:A4, or type
A2:A4. If you prefer whole columns, typeA:A—but avoid whole-column references if the sheet contains other text below your data, because those rows will also be evaluated. - Type a comma, then the criteria. The criteria is the text you want to match. You can type it directly in quotes, e.g.
"Acme", or refer to a cell that contains the text, e.g.D1. Using a cell reference makes it easy to change the criterion without editing the formula. Your formula so far:=SUMIF(A2:A4, "Acme". - Type a comma, then the sum range. This is the column of numbers to add when the text matches. Select B2:B4 or type
B2:B4. The sum range should be the same size as the criteria range; if it is not, Excel may return incorrect results. - Close the parenthesis and press Enter. The complete formula is
=SUMIF(A2:A4, "Acme", B2:B4). In the example data, this returns 700 (500 + 200). - Copy the formula down or across if needed. If you want to sum for several different text labels, put each label in its own cell (e.g. D1 = "Acme", D2 = "Beta") and write the formula once with a relative reference to D1, then copy it down. Use absolute references (e.g.
$A$2:$A$4and$B$2:$B$4) if you do not want the ranges to shift when copying. - Use wildcards for partial text matches. SUMIF supports the question mark (?) to match any single character and the asterisk (*) to match any sequence of characters. For example,
=SUMIF(A2:A4, "Ac*", B2:B4)sums amounts for any client whose name starts with "Ac". To find a literal question mark or asterisk, precede it with a tilde (~). - Make the match case-insensitive by default. SUMIF does not care about uppercase or lowercase—"acme" and "Acme" are treated the same. If you need a case-sensitive sum, use SUMPRODUCT with EXACT instead, but that is a separate formula.
Common Mistakes
- Mismatched range sizes. The criteria range and sum range must be the same number of rows and columns. If they differ, Excel may still calculate but the results will be wrong.
- Extra spaces in the text. A trailing space in a cell (e.g. "Acme ") will not match "Acme". Use TRIM on the source data or clean the text before summing.
- Forgetting quotes around literal text. If you type
=SUMIF(A2:A4, Acme, B2:B4)without quotes, Excel treats Acme as a named range and returns an error. Text criteria must be in double quotes unless you are referencing a cell. - Using the wrong wildcard. The asterisk matches any number of characters, including none; the question mark matches exactly one character. Mixing them up gives unexpected sums.
- Including the header row in the criteria range. If your header is "Client" and you search for "Client", the header row will be included in the sum if the sum range also includes the header (which is text and ignored). This is usually harmless but can confuse results if the header text appears in data.
- Assuming SUMIF is case-sensitive. It is not. If you need case-sensitive matching, SUMIF will not do it.
Tips
- Use a cell reference for the criteria so you can change the text without editing the formula. For example, put "Acme" in D1 and use
=SUMIF(A2:A4, D1, B2:B4). - Combine SUMIF with wildcards to sum by prefix, suffix, or contains. For example,
"*Corp"matches any text ending in "Corp". - If you need to sum with multiple text conditions (e.g. client = "Acme" AND status = "Paid"), use SUMIFS instead. SUMIFS supports multiple criteria ranges and is the correct tool for that job.
- Format the result cell as currency or number to make the sum readable.
- Use whole-column references (A:A, B:B) only when your data starts at row 1 and has no other text below; otherwise, use a specific range or an Excel Table with structured references.
Troubleshooting
- The formula returns 0 when you expect a sum. Check for extra spaces, non-printing characters, or mismatched case (though case should not matter). Use
=TRIM(A2)in a helper column to clean text, or use Find & Replace to remove spaces. Also verify the criteria range actually contains the text you are searching for—a typo in the criteria will return 0. - You see #VALUE!. This usually means the sum range contains text that cannot be converted to a number, or the criteria is not properly quoted. Ensure the sum range contains only numbers or blank cells.
- The sum is too high or too low. Confirm the criteria range and sum range are the same size and aligned. If you copy the formula, check that relative and absolute references are used correctly.
- Wildcards do not work. In some Excel settings, wildcards may be disabled. Check Excel Options > Advanced > "Enable wildcards in formulas" (wording may vary by version). If wildcards are off, use SEARCH with SUMPRODUCT instead.
- Text looks identical but does not match. There may be hidden characters. Use
=LEN(A2)to check length, or=CODE(MID(A2,1,1))to inspect the first character. Clean the data with Power Query or Text to Columns if needed.
Frequently Asked Questions
Can SUMIF match partial text?
Yes, use wildcards: * for any number of characters, ? for a single character. For example, "Ac*" matches "Acme" and "Acorn".
Is SUMIF case-sensitive?
No. SUMIF treats uppercase and lowercase as the same. For case-sensitive sums, use SUMPRODUCT with EXACT.
What is the difference between SUMIF and SUMIFS?
SUMIF handles one condition. SUMIFS handles multiple conditions and is the better choice when you need to sum based on two or more text criteria.
Can I use a cell reference as the criteria?
Yes. Instead of typing "Acme" in quotes, point to a cell that contains the text, e.g. =SUMIF(A2:A4, D1, B2:B4). This makes the formula dynamic.
Why does my SUMIF return 0 even though the text exists?
Check for extra spaces, hidden characters, or a mismatch in the range sizes. Also ensure the criteria text is spelled exactly as in the data, and that the sum range contains numbers, not text.
Can SUMIF sum numbers based on text in another sheet?
Yes, reference the other sheet in the ranges, e.g. =SUMIF(Sheet2!A2:A4, "Acme", Sheet2!B2:B4). Make sure the sheet name is spelled correctly and contains no spaces, or enclose it in single quotes if it does.