Issue finding a formula that works on a cell with multiple values (codes)

MPFraser7

New Member
Joined
Dec 14, 2016
Messages
34
Codes Formula
A001,A002 (return 10+20+30=60)
B001 (return 40=40)

Code Data1 Data2
A001 10 20
A002 30
B001 40


I have two tables, one with the Codes and Formula columns, the second with the Code, Data1 and Data2 column. In the codes column, the codes are entered in one cell and are comma separated. I'm trying to enter a formula that selects the comma separated codes and returns Data1 and Data2 values from the second table when the codes match. It would be easy to do if I was to split the Codes column into two or more, but I have to keep multiple codes per cell. I'm writing in my second language so please let me know if I should explain it better.
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
My table didn't work as intended.

Codes: row 1 = A001, A003 row 2 = B001
Formula: row 1 = (return 10+20+30=60) row 2 = (return 40=40)

Code: Row 1 = A001 Row 2 = A002 Row 3 = B001
Data1: Row 1 = 10 Row 2 = 30 Row 3 =0
Data2: Row 1 = 20 Row 2 = 0 Row 3 = 40
 
Upvote 0
Row\Col
A​
B​
C​
1​
CodesFormula
2​
A001,A002
60
3​
B001
40
4​
5​
CodeData1Data2
6​
A001
10
20
7​
A002
30
8​
B001
40

In B2 control+shift+enter, not just enter, and copy down:

=SUM(IF(ISNUMBER(SEARCH($A$6:$A$8&",",$A2&",")),$B$6:$C$8))
 
Upvote 0
If A8 is blank, the formula in B2 returns 100. I want to modify it so that it would still return 60, can you please instruct me on how to do so? Other than that, the formula works very well and will be put to good use. Thanks!
 
Upvote 0
If A8 is blank, the formula in B2 returns 100. I want to modify it so that it would still return 60, can you please instruct me on how to do so? Other than that, the formula works very well and will be put to good use. Thanks!

Right. In B2 control+shift+enter and copy down:

=SUM(IF(ISNUMBER(SEARCH(IF($A$6:$A$8="","#",$A$6:$A$8)&",",$A2&",")),$B$6:$C$8))
 
Upvote 0

Forum statistics

Threads
1,215,724
Messages
6,126,485
Members
449,316
Latest member
sravya

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