Function · Math
Excel SUMIF function
The Excel SUMIF function adds numbers whose neighbor cells pass one test. A grocery-category example that totals $198.57.
Syntax =SUMIF(range, criteria, [sum_range])
=SUMIF(A2:A4,"Groceries",B2:B4)Arguments
| Name | Required | What to pass |
|---|---|---|
| range | Required | The cells to test, such as the category column. |
| criteria | Required | The test. A word such as Groceries, or a comparison in quotes such as ">100". |
| sum_range | Optional | The numbers to add. If omitted, range itself is added. It should be the same shape as range. |
Examples
Two grocery trips
=SUMIF(A2:A4,"Groceries",B2:B4)Result $198.57
| A | B | |
|---|---|---|
| 1 | Category | Amount |
| 2 | Groceries | 86.40 |
| 3 | Rent | 1900 |
| 4 | Groceries | 112.17 |
| 5 | Grocery total | 198.57 |
SUMIF adds a number only when a neighbor passes one test. The test range and the number range are separate arguments, and the number range is last. That order is the reverse of SUMIFS, which is the usual reason a formula that used to work breaks after a second condition is added.
The two grocery rows are $86.40 and $112.17, so the category total is $198.57. Rent is in the same block and is left out. The same layout, with a date test added, is the monthly budget in the how-to. Use SUMIFS once you have more than one condition. SUMIF cannot express “groceries and November” in a single criteria argument.