The SUMIF function adds up numbers in a range only when they meet a condition you specify. For example, you can total all sales for a specific product, sum expenses above a certain amount, or add up values in one column based on a match in another. The basic syntax is =SUMIF(range, criteria, [sum_range]). If you omit sum_range, Excel sums the cells in range itself.
What You’ll Need
- Microsoft Excel (365, 2021, 2019, or earlier) on Windows, Mac, or Excel for the web. The steps below use Excel 365 on Windows; Mac and web differences are noted.
- A worksheet with data arranged in columns or rows. For example, column A contains categories, column B contains amounts.
- Basic understanding of cell references (like
A2) and ranges (likeA2:A20).
Step-by-Step
- Identify your data layout. Decide which range contains the values you want to check (the range) and which range contains the numbers to sum (the sum_range). They can be the same range or different. Example:
A2:A10has product names,B2:B10has sales amounts. - Click an empty cell where you want the result to appear, such as
D2. - Type the formula start. Begin with an equals sign:
=SUMIF(. - Add the range argument. Select the cells to check for the condition, or type the range. For example:
=SUMIF(A2:A10,. - Add the criteria. This can be a number, text, expression, or cell reference. For text, use double quotes:
"Apples". For numbers, just type them:100. For expressions, use quotes:“>100”. For a cell reference, no quotes:D1. Continue:=SUMIF(A2:A10, "Apples",. - Add the sum_range (optional). If the cells to sum are different from the range being checked, add a comma and select those cells. For example:
=SUMIF(A2:A10, "Apples", B2:B10). If you omit this, Excel sums the cells in the range argument. - Close the parenthesis and press Enter. Excel displays the total. For the example above, if
B2:B10contains 10, 20, 30 for Apples and other values, the result would be the sum of only those amounts where column A says “Apples” (e.g., 60 if those are 10, 20, 30). - Use a cell reference for the criteria to make the formula dynamic. For instance, put “Apples” in
D1and use=SUMIF(A2:A10, D1, B2:B10). This lets you change the criteria without editing the formula. - For Mac and Excel for the web: The steps are identical. The only difference is keyboard shortcuts for copying formulas (Cmd+C/Cmd+V on Mac, Ctrl+C/Ctrl+V on Windows/web).
Common Mistakes
- Mismatched range sizes: The range and sum_range must be the same size. If they are not, Excel may return incorrect results or an error.
- Using quotes around numbers: For numeric criteria, do not put quotes around the number unless you are using a comparison like “>100”. For text, quotes are required.
- Forgetting the equals sign: Every formula must start with
=. If you typeSUMIFwithout the equals, Excel treats it as text. - Using wildcards incorrectly: Wildcards
*and?work with text criteria, but they must be inside quotes. For example,"*Apples"matches any text ending with “Apples”. - Summing text values: SUMIF only sums numeric values. If your sum_range contains text numbers, they are ignored unless you convert them to numbers.
Tips
- Use SUMIFS for multiple conditions: If you need more than one condition, use
=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. - Use wildcards for partial matches:
"*Apples"matches any text ending with “Apples”."A*"matches text starting with “A”."*mid*"matches text containing “mid”. - Use cell references for criteria: This makes your formula easier to update and less error-prone.
- Use the function wizard: Click the
fxbutton next to the formula bar, search for SUMIF, and fill in the arguments interactively. - Test with a small dataset: Verify your formula on a few rows before applying it to a large range.
Troubleshooting
- Formula returns 0: Check that the criteria match exactly. Text is case-insensitive but must match spelling and spaces. For numeric criteria, ensure the numbers are stored as numbers, not text.
- Formula returns #VALUE!: This often means the range and sum_range are different sizes. Correct the ranges to match.
- Formula returns #NAME?: This usually means you misspelled the function name or forgot quotes around text criteria. Check for typos.
- Formula returns #N/A: This is rare with SUMIF; it may indicate a problem with the criteria, such as referencing an error cell. Check the criteria cell for errors.
- Result is wrong but no error: Verify that your sum_range is correct. If you omitted sum_range, make sure the range actually contains the numbers you want to sum.
- Criteria with dates: Use a date in quotes:
"1/1/2024"or reference a cell containing a date. Ensure the date format is recognized by Excel.
Frequently Asked Questions
- Can SUMIF sum based on a partial text match? Yes, use wildcards. For example,
=SUMIF(A2:A10, "*Apples*", B2:B10)sums all cells in B where A contains “Apples” anywhere. - How do I sum if a cell is not empty? Use
"<>"as the criteria:=SUMIF(A2:A10, "<>", B2:B10)sums B where A is not blank. - Can I use SUMIF with a cell reference for the criteria? Yes, just reference the cell without quotes:
=SUMIF(A2:A10, D1, B2:B10). If D1 contains text, it works as a text match. - What is the difference between SUMIF and SUMIFS? SUMIF is for a single condition; SUMIFS is for multiple conditions and has a different argument order (sum_range comes first).
- Does SUMIF work with dates? Yes. Use a date in quotes or a cell reference. For example,
=SUMIF(A2:A10, ">="&DATE(2024,1,1), B2:B10)sums B where A is on or after January 1, 2024. - Why does my SUMIF ignore hidden rows? SUMIF does not ignore hidden rows; it sums all cells in the range regardless of visibility. To sum only visible rows, use SUBTOTAL or AGGREGATE.
Related
- Data Entry How to Do: Steps, Tools, and Accuracy Tips
- How to Select All Files in a Folder (Windows & Mac)
- Select All Cells in a Range: Excel & Sheets
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- Excel Age from Date of Birth with DATEDIF ExplainedTo calculate age in completed years in Excel, put the date of birth in A2 and enter =DATEDIF(A2,TODAY(),"Y")…
- Excel Shortcut for Removing a Filter: What WorksIn Excel for Microsoft 365 on Windows, press Ctrl+Shift+L to turn AutoFilter off or on; this removes the…
- How to Filter Dates in Excel: A Step-by-Step GuideTo filter dates in Excel, select a cell in your data, choose Data > Filter, open the dropdown…
- Round Down in Excel: Formulas for Specific Decimal PlacesTo round a value down to a chosen number of decimal places in Excel, use the ROUNDDOWN function.…
- Excel Table Filter Multiple Values: Methods That WorkTo filter an Excel table for several values, open a column’s filter arrow, clear Select All, and check…
- Median Formula Examples in Excel and by HandThe median is the middle value after a set of numbers is arranged from smallest to largest; with…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.