SOLVED

Compare cell value againt a string of text or data separated by comma in another cell

Copper Contributor

I have 2 lists of data in 2 different columns as "Set 1" and "Set 2". The value in cell (A2) under "Set 1" need to be compared with text in cell (B2) under "Set 2" and it can have comma separated values to be compared against and can also have duplicates values in it. I would like to find matching value for A2 in B2 (First one if there are duplicates) under "Set 2" and return it under "Match" i.e Column C and apply the same condition for the rest of the rows

 

vijay_kiran_2-1644529631651.png

 

 

6 Replies

@vijay_kiran

In B2:

 

=IF(ISNUMBER(FIND(","&A2&",",","&B2&",")),A2,"")

 

Fill down.

@Hans Vogelaar 

 

Thank you, that is almost what I was looking for. I believe there a small tweaking required though. Its not picking the value if it is not the first one in the cell. Just to clarify from my example, in row 2, its not picking PB and giving a blank as that was not the first one in the cell but its helped in row 3 cause PB is the first value in it and returning it. Same problem in row 4 & 5 and working in row 6 again and so on.

best response confirmed by vijay_kiran (Copper Contributor)
Solution

@vijay_kiran 

Sorry change it to

 

=IF(ISNUMBER(FIND(", "&A2&", ",", "&B2&", ")),A2,"")

@Hans VogelaarI was wondering if you can help & suggest on similar query once again, but this time with 1 change in the data and a another change in the desired outcome.

 

Data change: If I have more than 1 value in Set 1 (i.e again separated by a comma (, ) and I wanted compare all the values in Set 1 with all the values in Set 2.

 

Desired Outcome: After comparison of Set 1 with Set 2, wanted see the missing values from Set 2 in Column C (As shown in the pic). Could this be possible? I have tried with the same formula to see if I can find all the matching values in Column C, few showed accurately and some were missing that should have showed up as a match. So, I was wondering to find the missing ones this time to make it easy to see the difference as my data is bit larger than the one from the example below (Not sure if the text is clear to view.

 

vijay_kiran_1-1647888878352.png

 

Set 1Set 2Missing
PB, ZA, ZMAK, DL, GJ, GT, HM, HR, KA, LD, MH, PA, PC, PD, PE, PF, PG, PH, PJ, RH, RJ, TG, TN, UP, WB, XU, ZA, ZB, ZC, ZD, ZE, ZF, ZG, ZH, ZJ, ZK, ZM, ZN, ZP, ZR, ZSPB
ZAAK, DL, GT, HM, HR, JH, KA, KL, MH, PB, PC, PD, PE, PF, PG, PH, PJ, RH, TG, TN, UP, WB, XU, ZA, ZB, ZC, ZE, ZF, ZG, ZH, ZJ, ZK, ZL, ZM, ZN, ZP, ZR, ZS 
PB, HRDL, GJ, KA, MH, PB, PC, PD, PF, PH, TG, UP, ZA, ZB, ZC, ZE, ZF, ZG, ZH, ZJ, ZK, ZM, ZN, ZP, ZRHR
AK, KA, PD, ZAGJ, GT, HR, MH, PB, PC, PE, PF, PH, PJ, TG, TN, UP, ZA, ZB, ZC, ZE, ZH, ZJ, ZK, ZM, ZN, ZP, ZRAK, KA, PD
DA, DL, HR, KA, PB, PC, PD, PF, PH, ZA, ZB, ZC, ZJ, ZK, ZM, ZN, ZPDL, HR, KA, MH, PB, PC, PD, PE, PF, PH, UP, ZA, ZB, ZC, ZE, ZG, ZK, ZM, ZN, ZPDA, ZJ
PBDL, GJ, HR, KA, MH, PA, PC, PD, PF, PH, UP, ZA, ZB, ZC, ZE, ZH, ZJ, ZK, ZM, ZN, ZP, ZR 
PB, ZJPB, ZJ 

@vijay_kiran 

I get PB for the next to last one...

Here is a solution using a custom VBA function; you'll have to allow macros when you open the workbook.

1 best response

Accepted Solutions
best response confirmed by vijay_kiran (Copper Contributor)
Solution

@vijay_kiran 

Sorry change it to

 

=IF(ISNUMBER(FIND(", "&A2&", ",", "&B2&", ")),A2,"")

View solution in original post