Return multiple values in one cell from VLOOKUP

jcm900

New Member
Joined
Oct 13, 2019
Messages
5
Hi,

I am using this formula

=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))


to return more than one value in a cell from VLOOKUP in relation to this thread

https://www.mrexcel.com/forum/excel-questions/647235-vlookup-return-multiple-values-same-cell.html


It works fine except that some of the cells that are being searched have more than one value themselves so I need to use a "contains" expression rather than just equals.

I have tried a wildcard "*"& B11 &"*" which returns a result if the searched cell "contains" the value of the refernce cell but I seem to have lost the abilty to return more than one value in a cell. Am I putting the wildcrd in the wrong place?

Many thanks

Phil
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
I have added FALSE instead of "0" value as shown here

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

which gives an odd result woth some vakues returned correctly and some not. As you can see below the result should be red, blue, green but instead I only get two colours returned.


<style type="text/css"><!--td {border: 1px solid #ccc;}br {mso-data-placement:same-cell;}--></style><style type="text/css"><!--td {border: 1px solid #ccc;}br {mso-data-placement:same-cell;}--></style>
A1, A2Red
A1BlueRed, Green
A1Green
A2Purple
A2Orange
A3Yellow
A4Black
A5White
Lookup
a1

<colgroup><col style="width: 286px"><col width="740"><col width="168"></colgroup><tbody>
</tbody>
 
Upvote 0
Hi & welcome to MrExcel.
Try
=CHOOSE(SUMPRODUCT(--(ISNUMBER(SEARCH(B11,A1:A8)))),
VLOOKUP("*"&B11&"*",A1:B8,2,FALSE),
VLOOKUP("*"&B11&"*",A1:B8,2,FALSE)&", "&INDEX(B1:B8,MATCH(B11,A1:A8,0)+1),
VLOOKUP("*"&B11&"*",A1:B8,2,FALSE)&", "&INDEX(B1:B8,MATCH(B11,A1:A8,0)+1)&", "&INDEX(B1:B8,MATCH(B11,A1:A8,0)+2))
 
Last edited:
Upvote 0
If you have the TEXTJOIN function you could use
=TEXTJOIN(", ",1,IF(ISNUMBER(SEARCH(B11,A1:A8)),B1:B8,""))

Confirmed with Ctrl Shift Enter, not just Enter.
 
Upvote 0
Hi & welcome to MrExcel.
Try
=CHOOSE(SUMPRODUCT(--(ISNUMBER(SEARCH(B11,A1:A8)))),
VLOOKUP("*"&B11&"*",A1:B8,2,FALSE),
VLOOKUP("*"&B11&"*",A1:B8,2,FALSE)&", "&INDEX(B1:B8,MATCH(B11,A1:A8,0)+1),
VLOOKUP("*"&B11&"*",A1:B8,2,FALSE)&", "&INDEX(B1:B8,MATCH(B11,A1:A8,0)+1)&", "&INDEX(B1:B8,MATCH(B11,A1:A8,0)+2))

HI Fluff,

Thank you. I now get Red, Green, Purple returned

Cheers

Phil
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,213,492
Messages
6,113,967
Members
448,537
Latest member
Et_Cetera

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