lookup on cells with Comma separated value

huat8888

New Member
Joined
Nov 23, 2018
Messages
7
Hi All,


Need a help please with either using excel formula or Excel VBA to lookup cells with comma separated values.
I have 2 tables below: table 1 and table 2. I will like the Col B (2nd column) of Table 1 to return a true or yes when any of the value is in the Col A (first column) of table 2 are found in that cell.

Your advise here will be greatly appreciated.


Table 1
Col A: Cells to searchCol B:column to return lookup
apple, banana, orange, grapeyes
cherry, apple, tomatoyes
lettuce, strawberry, durianno
cucumber, grapeyes

<tbody>
</tbody>


Table 2
Col A: Items
grape
apple

<tbody>
</tbody>



Regards,
Lawrence
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Table 1
Col A: Cells to search
Col B:column to return lookupmy formula
apple, banana, orange, grapeyesyes#####row 21
cherry, apple, tomatoyesyes
lettuce, strawberry, duriannono
cucumber, grapeyesyes

Table 2
Col A: Items
graperow 30######
applerow 31=IF(ISERROR(SEARCH($A$30,A21)),IF(ISERROR(SEARCH($A$31,A21)),"no","yes"),"yes")

<colgroup><col><col><col span="12"></colgroup><tbody>
</tbody>
 
Upvote 0
Hi,

This will do what you asked, you can have as many items in your Table 2 as you want.
Notice my sample in A7 where the data includes "pineapple", the result is Correct as No even thou "apple" is in the list in Table 2:


Book1
AB
1Table 1
2Col A: Cells to searchCol B:column to return lookup
3apple, banana, orange, grapeYes
4cherry, apple, tomatoYes
5lettuce, strawberry, durianNo
6cucumber, grapeYes
7banana, pineappleNo
8
9
10Table 2
11Col A: Items
12grape
13apple
14cherry
15watermelon
Sheet513
Cell Formulas
RangeFormula
B3=IF(ISNUMBER(LOOKUP(2,1/SEARCH(" "&A$12:A$15&","," "&A3&","))),"Yes","No")
 
Upvote 0
oldbrewer ,

I think your formula works for 2 cells (row 30 and row 31) only?. If there is more data, we will have to length the formula adding in additional search() formula?
i appreciate you sharing your formula and thank you!
 
Upvote 0
Hi,

This will do what you asked, you can have as many items in your Table 2 as you want.
Notice my sample in A7 where the data includes "pineapple", the result is Correct as No even thou "apple" is in the list in Table 2:

AB
1Table 1
2Col A: Cells to searchCol B:column to return lookup
3apple, banana, orange, grapeYes
4cherry, apple, tomatoYes
5lettuce, strawberry, durianNo
6cucumber, grapeYes
7banana, pineappleNo
8
9
10Table 2
11Col A: Items
12grape
13apple
14cherry
15watermelon

<colgroup><col style="width: 25pxpx"><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet513

Worksheet Formulas
CellFormula
B3=IF(ISNUMBER(LOOKUP(2,1/SEARCH(" "&A$12:A$15&","," "&A3&","))),"Yes","No")

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>

Thank you jtakw,

Your formula is very helpful. Will you explain to me how does this formula add up to function to what is needed please?


 
Upvote 0
Thank you jtakw,
Your formula is very helpful. Will you explain to me how does this formula add up to function to what is needed please?

You're welcome.

The LOOKUP is looking for the value of 2 within the SEARCH results, we divide 1 by the search results, thereby ensuring the result will Never be Greater than 1, since LOOKUP can Not find 2, it returns, if any, the Last found value by the SEARCH.

This can also be accomplished by using the "Big Num" ( 9.99999999999999E+307 ) in place of 2, and do away with the 1/ part.
 
Upvote 0

Forum statistics

Threads
1,214,922
Messages
6,122,281
Members
449,075
Latest member
staticfluids

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