The SUMIF formula in Excel adds up numbers in a range only when they match a condition you specify. Its syntax is =SUMIF(range, criteria, [sum_range]), where range is the cells to check, criteria is the condition (like “>100” or “Apples”), and sum_range is the actual cells to add if the condition is met (if omitted, Excel sums the range itself).
What SUMIF Does and When to Use It
SUMIF is one of Excel’s oldest conditional functions, introduced in Excel 2007. It lets you total values based on a single criterion, saving you from manually filtering or writing long IF formulas. You might use it to sum sales for a specific product, total hours worked by one employee, or add up expenses over a certain amount.
For example, if column A lists product names (A2:A100) and column B lists sales amounts (B2:B100), the formula =SUMIF(A2:A100,"Apples",B2:B100) returns the total sales for Apples only.
How the Syntax Works: Range, Criteria, Sum_Range
The function takes three arguments, with the third being optional:
- Range – the cells you want to evaluate against the condition. This can be a single column, row, or a block of cells.
- Criteria – the condition that determines which cells to include. It can be a number, text, expression (like “>50”), or a cell reference containing the condition.
- Sum_range – the actual cells to add. If you leave it out, Excel sums the range itself. When you include it, the sum_range should be the same size and shape as the range, or Excel will adjust it automatically (but it’s safer to keep them aligned).
Example: With quantities in A2:A10 and prices in B2:B10, =SUMIF(A2:A10,">5",B2:B10) adds all prices where the quantity is greater than 5.
Using Text, Numbers, and Wildcards in Criteria
Criteria can be a number (like 10), a text string (like "North"), or an expression with a comparison operator. For text, you can use wildcards:
"*"matches any sequence of characters –=SUMIF(A2:A10,"*East*",B2:B10)sums all rows where column A contains the word “East”."?"matches any single character –=SUMIF(A2:A10,"A?",B2:B10)matches “A1”, “AB”, etc.
For numeric comparisons, enclose the operator in quotes: =SUMIF(B2:B10,">=100") sums all values in B2:B10 that are 100 or more. To use a cell reference in the criteria, concatenate with an ampersand: =SUMIF(B2:B10,">"&D1) where D1 holds the threshold.
SUMIF vs SUMIFS: Which One to Use?
SUMIF handles only one condition. If you need two or more criteria, use SUMIFS, which has a different argument order: =SUMIFS(sum_range, criteria_range1, criteria1, [criteria_range2, criteria2], ...). The sum_range comes first in SUMIFS, but last in SUMIF. A common mistake is mixing up the order.
Example: To sum sales in column C where product is “Apples” (column A) and region is “North” (column B), use =SUMIFS(C2:C100,A2:A100,"Apples",B2:B100,"North").
For a single condition, SUMIF is simpler and slightly faster. For multiple conditions, SUMIFS is the correct choice. Both support wildcards and comparison operators.
Common Errors and How to Fix Them
- #VALUE! error – often caused by mismatched range sizes. Ensure
rangeandsum_rangeare the same size, or Excel may return an error. - Wrong results with text criteria – if your criteria text contains spaces or special characters, Excel may not match exactly. Use TRIM or ensure the cell values have no extra spaces.
- Criteria with dates – dates must be entered as text in quotes or as a serial number. For example,
=SUMIF(A2:A10,">="&DATE(2025,1,1),B2:B10)sums values where the date in column A is on or after January 1, 2025. - Using SUMIF with entire columns – while you can write
=SUMIF(A:A,"Apples",B:B), it’s slower. Limit to the actual data range for better performance.
Using SUMIF with Cell References and Other Functions
You can combine SUMIF with other functions. For instance, to sum the top 5 values that meet a condition, you’d need an array formula, but for simple cases, you can use SUMIF with a helper column. A more advanced approach uses SUMPRODUCT, but that’s beyond SUMIF.
You can also nest SUMIF inside other formulas, like =IF(SUMIF(A2:A10,"Apples",B2:B10)>100,"High","Low").
For dynamic criteria, use a cell reference: =SUMIF(A2:A10,D1,B2:B10) where D1 contains the product name. This makes your formula easy to update without editing the formula itself.
Frequently Asked Questions
Can SUMIF add cells based on partial text match? Yes, use wildcards. For example, =SUMIF(A2:A10,"*East*",B2:B10) sums all rows where column A contains “East” anywhere in the text.
Why does my SUMIF return 0 even though there are matching values? Check for hidden characters, leading/trailing spaces, or that the criteria text matches exactly. Also ensure the sum_range is correctly aligned. If you’re comparing numbers stored as text, convert them to numbers.
Can I use SUMIF with multiple conditions? No, SUMIF is for a single condition. Use SUMIFS instead, which accepts up to 127 range/criteria pairs.
Does SUMIF work in Google Sheets? Yes, SUMIF works the same way in Google Sheets, but the syntax is identical. However, in Google Sheets, you can also use SUMIFS with the same argument order as Excel.
How do I sum values that are not equal to something? Use the not-equal operator: =SUMIF(A2:A10,"<>Apples",B2:B10) sums all rows where column A is not “Apples”.
Can I use SUMIF with dates? Yes, but you must format the criteria correctly. Use a date serial number or the DATE function, and enclose comparison operators in quotes.
Related
- Computer System Shortcut Keys: The Essential List
- COUNTA in Google Sheets: Count Non-Empty Cells
- How to Replace a Value in a Python Dictionary
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- PostgreSQL Window Functions: Queries, Frames, and ExamplesPostgreSQL window functions calculate a result across related rows while keeping each row in the query result. Use…
- Excel INDIRECT Function: How to Use It with Cell ReferencesTo make Excel interpret text as a cell reference, use INDIRECT. With “B3” in A1 and 42 in…
- COUNTIF Greater Than in Excel: Formula and ExamplesTo count values greater than a number in Excel, use =COUNTIF(B2:B20,">100"), assuming the values are in B2:B20 and…
- Excel Formula to Reference a Sheet Name from a CellTo reference a worksheet named in a cell, use Excel’s INDIRECT function. If A1 contains the sheet name…
- Excel COUNTIF Criteria: Rules, Examples, and FixesIn Excel, COUNTIF criteria are the conditions that tell the COUNTIF function which cells to count. The syntax…
- SUMIF Formula Criteria Examples for Excel: Rules and TipsUse Excel’s SUMIF function to add values that match one condition, such as a product name, a minimum…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.