Sum based on looking up mutliple comma seperated values.

Ronanm

Board Regular
Joined
Nov 13, 2010
Messages
107
Hi

In Cell E2 below I have the formula =SUMPRODUCT(SUMIF($A$2:$A$5,MID(SUBSTITUTE(D2,",",""),ROW(INDIRECT("1:"&LEN(SUBSTITUTE(D2,",","")))),4),$B$2:$B$5)) and it works a treat.
However I need the same in G2 to J2 (the ?'s), where it pulls out the values based on the Heading in G1 to J2. Thanks if you can help.



CodeAmountA123A124A125A126
A123
5​
A124,A126
15​
???
A124
6​
A125
8​
A126
9​
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
How about
=SUMIF($A$2:$A$5,G1,$B$2:$B$5)
 
Upvote 0
Apologies... I rushed when sent that out.. It should have been; As there can be repeated values. Sorry

CodeAmountA123A124A125A126
A123
5​
A124,A126,A124
21​
???
A124
6​
A125
8​
A126
9​
 
Upvote 0
I don't understand, you said you wanted the values based on the headers in G1:J1.
What does the value in D2 have to do with it?
 
Upvote 0
Sorry. What I should have said was... In E2 I have the formula =SUMPRODUCT(SUMIF($A$2:$A$5,MID(SUBSTITUTE(D2,",",""),ROW(INDIRECT("1:"&LEN(SUBSTITUTE(D2,",","")))),4),$B$2:$B$5))
 
Upvote 0
Your question was about getting the values in G2:J2 based on the values in G1:J1.
So I'll ask again, what does D2 have to do with your question?
 
Upvote 0
Can you please answer my question?
 
Upvote 0
In E2 I have the formula =SUMPRODUCT(SUMIF($A$2:$A$5,MID(SUBSTITUTE(D2,",",""),ROW(INDIRECT("1:"&LEN(SUBSTITUTE(D2,",","")))),4),$B$2:$B$5)).
In D2 I have the values A124,A126,A124

The result in E2 is 21. This is from summing up the Amounts for two A124 and one A126 from Cell D2.
I would like a formula to calculate the totals over in cells G2- J2 (the 's) using the Headers in G1 - J1.
CodeAmountA123A124A125A126
A123
5​
A124,A126,A124
21​
????
A124
6​
A125
8​
A126
9​
 
Upvote 0
Have you tried the formula I suggested in post#2?
 
Upvote 0

Forum statistics

Threads
1,223,958
Messages
6,175,633
Members
452,661
Latest member
Nonhle

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