Sum if lookup value matches

jayjay226

New Member
Joined
Aug 13, 2015
Messages
14
Hi everyone

Hoping someone can help...

I have 2 tables on different sheets like so:

Sheet 1
[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD][/TD]
[TD]Jan[/TD]
[TD]Feb[/TD]
[TD]Mar[/TD]
[TD]Apr[/TD]
[TD]May[/TD]
[TD]Jun[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Apples
[/TD]
[TD]10% Off[/TD]
[TD]25% Off[/TD]
[TD]20% Off[/TD]
[TD]20% Off[/TD]
[TD]10% Off[/TD]
[TD]20% Off[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Oranges[/TD]
[TD]20% Off[/TD]
[TD]25% Off[/TD]
[TD]10% Off[/TD]
[TD]20% Off[/TD]
[TD]10% Off[/TD]
[TD]20% Off[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Bananas[/TD]
[TD]25% Off[/TD]
[TD]20% Off[/TD]
[TD]10% Off[/TD]
[TD]25% Off[/TD]
[TD]10% Off[/TD]
[TD]25% Off[/TD]
[/TR]
</tbody>[/TABLE]

Sheet 2
[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD]H[/TD]
[TD]I[/TD]
[TD]J[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD][/TD]
[TD]Jan[/TD]
[TD]Feb[/TD]
[TD]Mar[/TD]
[TD]Apr[/TD]
[TD]May[/TD]
[TD]Jun[/TD]
[TD]10% Off[/TD]
[TD]20% Off[/TD]
[TD]25% Off[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Apples[/TD]
[TD]20[/TD]
[TD]35[/TD]
[TD]42[/TD]
[TD]10[/TD]
[TD]12[/TD]
[TD]13[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Oranges[/TD]
[TD]15[/TD]
[TD]35[/TD]
[TD]10[/TD]
[TD]9[/TD]
[TD]56[/TD]
[TD]12[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Bananas[/TD]
[TD]5[/TD]
[TD]6[/TD]
[TD]7[/TD]
[TD]18[/TD]
[TD]4[/TD]
[TD]12[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

In cells H2:J4, I want to sum the values in B:G if the lookup value for that month in table 1 matches the heading in H1:J1

Sheet 2 is a lot longer than Sheet 1 with the names appearing multiple times so I don't think I can just do a basic SUMIF

Thanks in advance for you help
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Values for H2:J2 (Apples) should be 32, 65 and 35 respectively
Values for H3:J3 (Oranges) should be 66, 36 and 35 resepctively

What I'm trying to do is find out from table 1 which months we ran the promotion in the heading (e.g. "10% off) for that product, then sum up the values for the matching months.

So the Apples line for example, under "10% off" it would add up the values for Jan and May, 20% would add up Mar, Apr, and June, and so on

Thanks again
 
Upvote 0
Each product appears only once in Sheet 1 (sort of like a master list) but will appear multiple times in the sales data in Sheet 2 with different values

Thanks
 
Upvote 0
In H2 of Sheet2 control+shift+enter, not just enter, copy across, and down:

=SUM(IF(Sheet1!$A$2:$A$4=$A2,IF(Sheet1!$B$2:$G$4=H$1,$B2:$G2)))
 
Upvote 0
An afterthought, using SUMIFS...

In H2 of Sheet2 just enter, copy across, and down:

=SUMIFS($B2:$G2,INDEX(Sheet1!$B$2:$G$4,MATCH($A2,Sheet1!$A$2:$A$4,0),0),H$1)

which would be a tad faster.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,241
Members
452,622
Latest member
Laura_PinksBTHFT

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