Using formulas/functions in the Criteria part of SUMIF function

jardenp

Active Member
Joined
May 12, 2009
Messages
373
Office Version
  1. 2019
  2. 2016
  3. 2013
  4. 2011
  5. 2010
Platform
  1. Windows
ABCDE
1/1/201211/1/2012Expected result: 4 (1+3)
1/8/201232/1/2012Expected result: 12 (7+5)
2/2/201253/1/2012Expected result: 9 (9)
2/7/201271/1/2013Expected result: 11 (11)
3/2/201292/1/2013Expected result: 28 (13+15)
1/2/201311
2/3/201313
2/4/201315

<tbody>
</tbody>

What I'm trying to accomplish is that the cells in Column E return the sum of values in Column B for all rows where the month and year of Column A matches the month and year of the adjacent cell in Column D. For example, The formula in E1 would look for rows in Column A with a month value of 1 and a year value of 2012 and return the sum of Column B values for those rows. In this example, it would be rows 1 and 2.

Would I use SUMIF here? Maybe using some form of AND(MONTH(A)=MONTH(D), YEAR(A)=YEAR(D))?

Thanks.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Try

=SUMPRODUCT(--(MONTH(A$1:A$100)=MONTH(D1)),--(YEAR(A$1:A$100)=YEAR(D1)),B$1:B$100)
 
Upvote 0
That works perfectly. Thank you very much.

I'm not familiar with the use of "--" in the formula. What does that do?
 
Upvote 0
-- converts an array of False/True to an array of 0/1that Sumproduct can process.
 
Upvote 0
I just experimented and figured out how I can add other criteria. This is great. Thanks VoG. Definitely not the first time you've helped me.
 
Upvote 0

Forum statistics

Threads
1,216,100
Messages
6,128,834
Members
449,471
Latest member
lachbee

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top