Vlookup to return multiple values in same cell

KimC2504

Board Regular
Joined
Jul 17, 2012
Messages
141
Hi All,

Traditionally the vookup will return the first value it can match. I can return multiple values on different lines using an array formula but this is not useful.

In the example below I have table array A1:B8. Lookup criteria in cell A11 and want to return MULTIPLE values from column B in cell B11.

Any suggestions? I would prefer to not use VBA if possible
A
B
1
A1
Red
2
A1
Blue
3
A1
Green
4
A2
Purple
5
A2
Orange
6
A3
Yellow
7
A4
Black
8
A5
White
9
10
Lookup
11
A1
Red, Blue, Green

<TBODY>
</TBODY>
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Hi All,

Traditionally the vookup will return the first value it can match. I can return multiple values on different lines using an array formula but this is not useful.

In the example below I have table array A1:B8. Lookup criteria in cell A11 and want to return MULTIPLE values from column B in cell B11.

Any suggestions? I would prefer to not use VBA if possible
AB
1A1Red
2A1Blue
3A1Green
4A2Purple
5A2Orange
6A3Yellow
7A4Black
8A5White
9
10Lookup
11A1Red, Blue, Green

<tbody>
</tbody>

There is no native function which can concatenate multiple values in a single cell. You could either get the results in a horizontal multi-cell record or invoke a function written in VBA which constructs a single cell result. Which would you like to have?
 
Upvote 0
Hi Aladin, I was going to use a horizontal multi-cell record until I received the wonderful VBA function. I am so happy with it :)
 
Upvote 0
Why not...

=vlookup()&", "&vlookup()&", "&...

Or build in some error handling if you want a cleaner look...

=iferror(vlookup(1),"")&if(isna(vlookup(1)),"",", "&vlookup(2))&if(or(isna(vlookup(1)),isna(vlooup(2))),"",", "&vlookup(3))

Something along those lines.
 
Upvote 0
This would work as long as the number of colors returned never exceeded three:

=CHOOSE(SUMPRODUCT(--(B11=A1:A8)),
VLOOKUP(B11,A1:B8,2,0),
VLOOKUP(B11,A1:B8,2,0) & ", " & INDEX(B1:B8,MATCH(B11,A1:A8,0)+1),
VLOOKUP(B11,A1:B8,2,0) & ", " & INDEX(B1:B8,MATCH(B11,A1:A8,0)+1) & ", " & INDEX(B1:B8,MATCH(B11,A1:A8,0)+2))
 
Upvote 0
Dear Sir,

I have an excel file as below

B
1 English - Nishant (1-3), Hindi Anand (4-6)
2 Hindi - Anand (4-6), English (1-3)


and so on. above data is in B1 AND B2

nOW i WANT as if I search for "Anand" and it returns me value, say in D1 AS English - Nishant (1-3), Hindi Anand (4-6), Hindi - Anand (4-6), English (1-3).

all cell containing string "Anand" in a column B. must be combined in cell D1.
 
Upvote 0

Dear Sir

Thanks for your prompt reply,
Actually I have a time table in school having subject name, day and class in one cell, In a single column say Period 1, there may be more than one occurance of that particular teacher. so I need a forumula that as I put name of teacher in cell and it returns me his time table according to periods 1 - 8.
 
Upvote 0

Forum statistics

Threads
1,214,786
Messages
6,121,553
Members
449,038
Latest member
Guest1337

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