How to Write a SUMIF Formula in Excel

Formulas & functions · Updated November 23, 2026

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 (like A2:A20).

Step-by-Step

  1. 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:A10 has product names, B2:B10 has sales amounts.
  2. Click an empty cell where you want the result to appear, such as D2.
  3. Type the formula start. Begin with an equals sign: =SUMIF(.
  4. Add the range argument. Select the cells to check for the condition, or type the range. For example: =SUMIF(A2:A10,.
  5. 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",.
  6. 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.
  7. Close the parenthesis and press Enter. Excel displays the total. For the example above, if B2:B10 contains 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).
  8. Use a cell reference for the criteria to make the formula dynamic. For instance, put “Apples” in D1 and use =SUMIF(A2:A10, D1, B2:B10). This lets you change the criteria without editing the formula.
  9. 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 type SUMIF without 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 fx button 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

  1. 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.
  2. 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.
  3. 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.
  4. 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).
  5. 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.
  6. 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

Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.

More in Formulas & functions

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.