**Please Note: **
This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Office 365. If you are using an earlier version (Excel 2003 or earlier), *this tip may not work for you*. For a version of this tip written specifically for earlier versions of Excel, click here: Selective Summing.

Excel contains a built-in function that allows you to easily specify which values should be summed from a column. This function, SUMIF, is used in the following manner:

=SUMIF(Testrange,Test,Sumrange)

In this usage, SUMIF uses three arguments. The first is the range of cells to be tested, the second is the test to use, and the third is the cells from which the sums are to be pulled. For instance, let's say that the cells in B2 through B27 contained days of the week (Monday, Tuesday, etc.), and that cells C2 through C27 contained the gross sales generated on those days. If you wanted to only get a sum for the sales on Mondays, you could use the following formula, perhaps in cell C28:

=SUMIF(B2:B27,"Monday",C2:C27)

This examines B2 through B27 and checks if the cell contains the text "Monday." If it does, then the corresponding cell is selected from C2 through C27 and added to the sum.

If you wanted to quickly pull sales totals for different days, you could modify the above scenario just a bit. All you would need to do is place the day on which you want to sum in cell B28. Then, in cell C28 you would place the following formula:

=SUMIF(B2:B27,B28,C2:C27)

Now the test for SUMIF is taken from cell B28. Thus, if B28 contains "Monday," then the sum will reflect the total of Monday's sales. If it contains "Wednesday," then Wednesday's sales will be summed, and so forth.

*ExcelTips* is your source for cost-effective Microsoft Excel training.
This tip (7013) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Office 365. You can find a version of this tip for the older menu interface of Excel here: **Selective Summing**.

**Save Time and Supercharge Excel!** Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out *Excel 2010 VBA and Macros* today!

When converting between measurement systems, you might want to use two cells for each type of measurement. Make a change ...

Discover MoreNeed to figure out how many rows in a worksheet meet two criteria that you specify? Here's how to get the info you desire.

Discover MoreWhen analyzing data, you may have a need to calculate a sum based on just part of a particular cell. This tip examines ...

Discover More**FREE SERVICE:** Get tips like this every week in *ExcelTips,* a free productivity newsletter. Enter your address and click "Subscribe."

2018-12-03 22:17:20

Roy

For instance, =SUMIF(J10:J13,">13",H5:h6) might only meet the condition in J13 which is its 4th element. It will pick the 4th element of the range of interest, H5:H6. Umm... That would be H8. And it is.

I've never seen a good explanation for that, though it logically extends from some ways one might (poorly) write the function in code. It certainly does let one use ranges that are not "relative" to each other, J10:J13 lying across, left/right, from H10:H13, for example and the 10's being compared, etc. But... that would have been achieved just by taking what people put in literally, instead of "interpreting" it. So... no explanation.

Simply using "H5" would give the same result as above. I guess if one always built the test range using OFFSET, etc. to calculate its end based upon the range of summing interest... Lordy though, that's putting the cart before a LOT of horses.

Never know though, that might be a useful thing for some trick providing what Excel doesn't see fit to program in.

But it isn't "incorrect" - just surprising and always pretty undesired.

2018-12-01 06:14:32

Alex B

In addition to what Col said, SumIf also has a bug in it and instead of giving you an error message if you select disparate ranges for your sum range and criteria range, it will give you an incorrect result.

SumIfs under the same conditions gives you #Value making you aware of the error.

2018-12-01 05:35:56

Col Delane

The syntax of the SUMIFS function is also more logical than SUMIF as the sum_range argument is listed first, with each set of criteria_range and criteria following, viz;

=SUMIFS( sum_range, criteria_range1, criteria1, [criteria_range2, criteria2], ... )

Got a version of Excel that uses the
ribbon interface (Excel 2007 or later)?
**This site is for you!** If you
use an earlier version of Excel, visit
our *ExcelTips* site focusing on the menu interface.

**FREE SERVICE:** Get tips like this every week in *ExcelTips,* a free productivity newsletter. Enter your address and click "Subscribe."

Copyright © 2019 Sharon Parq Associates, Inc.

## Comments