How to Lookup Values separated by commas ?

navinrb

Board Regular
Joined
Jun 9, 2020
Messages
82
Office Version
  1. 2019
Platform
  1. Windows
  2. Mobile
  3. Web
Suppose i have lookup values in sheet 1as
Apple,orange,banana
Carrot, watermelon
Apricot, grapes

I want to lookup above fruits in following table in sheet 2
Fruits. Qty. . Price
Apple.
Banana.
Orange.
Watermelon.
Grapes
Apricot
Carrot.
 
Last edited:

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
What do you want to do when you find each fruit? It would be easier to help if you could use the XL2BB add-in (icon in the menu) to attach a screenshot (not a picture) of your sheet. Alternately, you could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary).
 
Upvote 0
What do you want to do when you find each fruit? It would be easier to help if you could use the XL2BB add-in (icon in the menu) to attach a screenshot (not a picture) of your sheet. Alternately, you could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary).
I think my query is clear ..i just wann lookup comma separated items in vertically arranged item list to return price.
 
Upvote 0
Please note that it is not always obvious on what you may want to do so I will give you a general idea. You would have to split each group in Sheet1 into an array and then loop through each array item to find it on Sheet2 and return the corresponding price. This appears to be fairly straight forward. If you want me to suggest a macro then please review my request in Post #2.
 
Upvote 0
This could also be done with a Power Query Merge of the two tables/ranges, however, if you would like an example of how to do it, please respond to Mumps request in Post #2. It is forum courtesy to provide as requested and not expect someone to recreate your data to give you a workable solution.
 
Upvote 0
Is this what you are trying to achieve?

navinrb.xlsm
AB
1Apple,orange,banana1
2Carrot, watermelon2
3Apricot, grapes3
Sheet1


navinrb.xlsm
AB
1Apple1
2Banana1
3Orange1
4Watermelon2
5Grapes3
6Apricot3
7Carrot2
Sheet2
Cell Formulas
RangeFormula
B1:B7B1=VLOOKUP("* "&A1&" *"," "&SUBSTITUTE(Sheet1!A$1:B$3,","," ")&" ",2,0)
 
Upvote 0
VLOOKUP("* "&A1&" *"," "&SUBSTITUTE(Sheet1!A$1:B$3,","," ")&" ",2,0

Is this what you are trying to achieve?

navinrb.xlsm
AB
1Apple,orange,banana1
2Carrot, watermelon2
3Apricot, grapes3
Sheet1


navinrb.xlsm
AB
1Apple1
2Banana1
3Orange1
4Watermelon2
5Grapes3
6Apricot3
7Carrot2
Sheet2
Cell Formulas
RangeFormula
B1:B7B1=VLOOKUP("* "&A1&" *"," "&SUBSTITUTE(Sheet1!A$1:B$3,","," ")&" ",2,0)
Thank you for your time but unfortunately what i want is just reverse of your solution . Means i want sheet 2 pricde to be filled in sheet 1.
 
Upvote 0
How would that look since the Sheet1 cells can contain multiple items that could be all different prices?

I think my query is clear
It seems this wasn't the case as at least 3 of us have looked without it being clear to us. ;)

So could you actually provide a small set of sample data and expected results with XL2BB as requested earlier.
 
Upvote 0
How would that look since the Sheet1 cells can contain multiple items that could be all different prices?

It seems this wasn't the case as at least 3 of us have looked without it being clear to us. ;)

So could you actually provide a small set of sample data and expected results with XL2BB as requested earlier.
Please have a look at screenshot.
IMG_20201013_130651.jpg
 
Upvote 0
Like this (for up to 5 items)?

navinrb.xlsm
AB
1Apple1
2Banana1
3Orange1
4Watermelon2
5Grapes3
6Apricot3
7Carrot2
Sheet2


navinrb.xlsm
AB
1Apple,orange,banana3
2Carrot,watermelon4
3Apricot,grapes,orange7
Sheet1
Cell Formulas
RangeFormula
B1:B3B1=SUMPRODUCT(IFERROR(VLOOKUP(TRIM(MID(SUBSTITUTE(","&A1,",",REPT(" ",100)),{1,2,3,4,5}*100,100)),Sheet2!A$1:B$7,2,0),0))
 
Upvote 0

Forum statistics

Threads
1,214,865
Messages
6,121,988
Members
449,060
Latest member
mtsheetz

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