The SUMIF function in Excel adds numbers in a range only when they meet a condition you specify. Its syntax is =SUMIF(range, criteria, [sum_range]); for example, =SUMIF(A2:A10, "Apples", B2:B10) adds all values in B2:B10 where the matching cell in A2:A10 equals “Apples”. If you omit the third argument, Excel sums the cells in the range itself.
What SUMIF Does and When to Use It
SUMIF is a conditional summing function. It scans a range of cells, checks each cell against a criterion, and adds up corresponding numbers. You use it whenever you need a total that depends on a category, a date, a text match, or a numeric threshold—for example, total sales for a specific product, total hours logged by one employee, or total expenses over a certain amount. It works on a single condition; if you need multiple conditions, use SUMIFS (with an S).
How to Write a SUMIF Formula
Start with an equals sign, then type SUMIF and an opening parenthesis. The three arguments are:
- range – the cells you want to check against the condition (e.g., A2:A20).
- criteria – the condition, in quotes if text or a comparison operator (e.g., “Apples”, “>100”, “<>“).
- sum_range – the cells to add (optional). If omitted, Excel sums the range itself.
For example, with product names in A2:A10 and sales in B2:B10, =SUMIF(A2:A10, "Apples", B2:B10) returns the total sales for Apples. If you put the criteria in a cell, say D2, use =SUMIF(A2:A10, D2, B2:B10)—no quotes around a cell reference.
Criteria: Text, Numbers, Dates, and Wildcards
The criteria argument is flexible. For text, use quotes: "Apples". For numbers, you can use a plain number (100) or a comparison like ">100" or "<="&D1. Dates work as numbers: ">"&DATE(2024,1,1) sums values after January 1, 2024. Wildcards are allowed: "A*" matches any text starting with A, "*apple*" matches text containing "apple", and "?" matches a single character. To sum an exact match that could be mistaken for a wildcard, use "~" before the character, e.g., "~?".
Common Mistakes and How to Fix Them
Several pitfalls trip up new users:
- Wrong range size – range and sum_range must be the same size; otherwise, Excel uses the top-left cell and expands to match, which often gives wrong results.
- Criteria as text vs. number – If your criteria cell contains a number formatted as text, SUMIF may not match. Use
VALUE()or ensure the cell is truly numeric. - Leading/trailing spaces – Extra spaces in text break matches. Use
TRIM()on the data or criteria. - Case sensitivity – SUMIF is not case-sensitive. "apples" matches "APPLES". If you need case-sensitive summing, use SUMPRODUCT with EXACT.
SUMIF vs. SUMIFS and Other Alternatives
SUMIF handles one condition; SUMIFS handles multiple and uses a different argument order: =SUMIFS(sum_range, criteria_range1, criteria1, [criteria_range2, criteria2], ...). For example, =SUMIFS(B2:B10, A2:A10, "Apples", C2:C10, "North") sums sales for Apples in the North region. If you need to sum based on a calculation or a more complex logic, use SUMPRODUCT, which can evaluate arrays, or FILTER (Excel 365) combined with SUM: =SUM(FILTER(B2:B10, A2:A10="Apples")). For counting instead of summing, use COUNTIF or COUNTIFS.
Using SUMIF with Dates and Blank Cells
Dates are stored as serial numbers, so comparisons work naturally. To sum values after a specific date, put the date in a cell (say D1) and use =SUMIF(A2:A10, ">"&D1, B2:B10). For blank cells, use "=" or "" to match empty cells, and "<>" to match non-blank cells. Be careful: "<>" will also match cells containing a zero-length string from formulas.
Frequently Asked Questions
Can I use SUMIF with a cell reference as criteria? Yes, just reference the cell directly, e.g., =SUMIF(A2:A10, D1, B2:B10). For text criteria, you don't need quotes if the cell contains the text.
Why is my SUMIF returning 0? Common reasons: criteria text doesn't match exactly (check spaces and case), the sum_range is the wrong size, or the criteria is a number stored as text. Use TRIM() and check the data types.
Does SUMIF work with wildcards? Yes, use * for multiple characters and ? for a single character. To match a literal asterisk or question mark, precede it with a tilde (~).
How do I sum if a cell contains a specific word? Use wildcards: =SUMIF(A2:A10, "*apple*", B2:B10) sums all rows where column A contains "apple" anywhere.
Can I sum based on color or formatting? No, SUMIF only looks at cell values, not formatting. For color-based summing, you'd need VBA or a helper column with a formula that detects the color (not available in standard functions).
Is SUMIF available in Google Sheets? Yes, the same syntax works in Google Sheets. The main difference is that in Google Sheets you might use FILTER more often, but SUMIF behaves identically.
Practical Example with Step-by-Step
Suppose you have a small expense table: A1 is "Category", B1 is "Amount". Rows 2-6 contain: Food 50, Travel 120, Food 30, Utilities 80, Travel 45. To total all Food expenses, enter in D1: =SUMIF(A2:A6, "Food", B2:B6). The result is 80 (50+30). If you want to total all amounts over 60, use =SUMIF(B2:B6, ">60") (omitting sum_range) which returns 200 (120+80).
Related
- What Is an Enum in Code? Definition & Usage
- How Is Progress 8 Calculated? GCSE Scores Explained
- Bosch 36V Brute Tough Drivers: What You Need to Know
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- DAX SUMIF: How to Sum Values by ConditionDAX has no standalone SUMIF function. To sum a column when a condition is true, create a measure…
- PV of Annuity Formula in Excel: Examples and TimingWith the annual interest rate in A2, the number of annual payments in B2, and each end-of-year payment…
- How to Align Dates in Excel: Format and Match ThemTo align dates visually, select the date cells and choose an alignment option in Home > Alignment, such…
- Excel Paste Special: Copy Values, Formulas, and MoreTo use Paste Special in Excel for Microsoft 365 on Windows, copy the source cells, select the destination,…
- IFERROR with XLOOKUP: Formula, Examples, and FixesWith the lookup value in E2, keys in A2:A5, and return values in B2:B5, use =IFERROR(XLOOKUP(E2,A2:A5,B2:B5),"Not found"). It…
- Microsoft Excel SUMIF Examples and How to Use ThemIn Microsoft Excel, SUMIF adds values that meet one condition. For example, with categories in A2:A6 and amounts…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.