Lookup multiple values in a single cell (separated by commas) and then return the values to a single cell (also comma separated)

Feagal

New Member
Joined
Jan 7, 2009
Messages
3
Sorry if that's a bit long winded...

Here's how it breaks down.

If I have, in one cell (call it D1):

EH,DR,HU

and in a lookup table on another sheet:
A B
1 ED T
2 EH F
3 DR G
4 HU H
5 SE E
6 YU E

I need to be able to lookup the values in D1 on the table and return the values in column B to a single cell (say E1), also comma separated...

eg...

F,G,H

Does that make sense or should I resubmit?

I've tried a few different ways but can't come up with anything...

There's more to the project, but this bit will help me get it off the ground and hopefully I'll be able to string the rest together.

Cheers guys! Great forum!
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Hi Feagal and welcome to the Board.

This is ugly but will do what you require, I'm sure there will be a heap of simpler and cleaner answers.
Assuming your lookup table is in A2:B7
and your initial info is in D1
Code:
=VLOOKUP(LEFT(D1,2),A2:B7,2,FALSE)&","&VLOOKUP(MID(D1,4,2),A2:B7,2,FALSE)&","&VLOOKUP(RIGHT(D1,2),A2:B7,2,FALSE)

Regards
Michael M
 
Upvote 0
Excel Workbook
ABCDE
1LookupResult*DataLookup
2EDT*EH,HU,SEF,H,E
3EHF*HU,DR,DRH,G,G
4DRG*EH,SE,HUF,E,H
5HUH*SE,DR,HUE,G,H
6SEE*SE,SE,YUE,E,E
7YUE*DR,ED,DRG,T,G
Sheet1


(If all entries are only 2 letters, use Michael's. If there is a chance that there will be ones with 3, or 5, or 1, or any number other than 2, mine will work)
 
Upvote 0
First, download and install the free add-in, Morefunc. Then define the following...

Insert > Name > Define

Name: Array

Refers to:

=EVAL("{"""&SUBSTITUTE(SUBSTITUTE($D$2," ",""),",",""",""")&"""}")

Click Ok

Then, assuming that A2:B7 contains the source data, try...

=SUBSTITUTE(MCONCAT(IF(ISNUMBER(FIND(","&$A$2:$A$7&",",","&D2&",")),","&$B$2:$B$7,"")),",",1)

...confirmed with CONTROL+SHIFT+ENTER.

Hope this helps!
 
Upvote 0
Hi there,


Thank you so much for your help... things are coming together.

However, one thing I forgot to mention - sometimes you won't have 3 seperate bits of data to lookup... sometimes, you will have 1 or 2 or possibly up to 30.

That makes things slightly harder I guess? Something I should have mentioned before I guess.

Any further help in this area would be much appreciated...

Cheers very much - hope you are all enjoying the start of the year so far...
 
Upvote 0
Hi Dominec,

I'm having problems getting it to work to be fair - it must be something I'm doing...

Will it cope with different numbers of data within each cell then?

I'll be working on it so will let you know if I manage to get it to work.


Ta,
S
 
Upvote 0
I'm having problems getting it to work to be fair - it must be something I'm doing...

Is the formula returning an error value? If so, which one?

Is the formula not returning the proper values? If so, can you provide an example?

Will it cope with different numbers of data within each cell then?

Yes...
 
Upvote 0
Hi Feagal,
Instead of constructing one complicated formula to fit all scenario, may i suggest you break it down into steps and get the thing done?

1) Separate the Data into Columns by using "Text to Columns"
2) Construct Vlookup formula for each "separted" cell (it should be easy)
3) CONCATENATE the results into one cell

Hope this helps.
 
Upvote 0
A few things...

1) I'm not sure why I included the part about defining the name 'Array'. It's completely not necessary.

2) The FIND function is case-sensitive. If you don't want the formula to be case-sensitive, replace FIND with SEARCH.

3) The formula needs to be confirmed with CONTROL+SHIFT+ENTER, not just ENTER.

4) I assumed that A2:B7 contains...

ED T
EH F
DR G
HU H
SE E
YU E

5) I assumed that D2 contains...

EH,DR,HU

6) Use the following formula instead, which will allow for inadvertent spaces between the values in D2...

=SUBSTITUTE(MCONCAT(IF(ISNUMBER(FIND(","&$A$2:$A$7&",",","&SUBSTITUTE(D2," ","")&",")),","&$B$2:$B$7,"")),",",1)

Hope this helps!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,991
Messages
6,122,628
Members
449,095
Latest member
bsb1122

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