Excel - How to vlookup to return multiple values?

overflew

I'm looking to use Excel to look up and return multiple reference values for a given key. VLookup does something very similar to what I need - but only returns a single match.

I assume it'll involve array-returning and handling methods, though I haven't dealt with these before. Some Googling starts to lean on the if([lookuparray]=[value],row[lookuparray]) as part of a solution - though I can't get it to return a single match...

For example, if I have this reference data:

Adam    Red
Adam    Green
Adam    Blue
Bob     Red
Bob     Yellow
Bob     Green
Carl    Red 

I'm trying to get the multiple return values on the right. (Comma separated, if possible)

Red      Adam, Bob, Carl
Green    Adam, Bob
Blue     Adam
Yellow   Bob

(I already have the key value on the left - no need to pull out those values)

Any help as to how to approach handling multiple values in th this context is apprecited. Thanks.

Dan

Assuming you want a formula approach as stated (not using VLOOKUP, but still a formula), here is how I laid out the data:

Data Layout

I then used the following formula in cell C12:

=INDEX($C$2:$C$8, SMALL(IF($B12=$B$2:$B$8, ROW($B$2:$B$8)-MIN(ROW($B$2:$B$8))+1, ""), 1))

This is an array formula so after you copy and paste it into the cell you have to hit Ctrl+Shift+Enter. I then just dragged it to the right and to the bottom.

If there is no value(s) remaining it gives the #NUM! error, I gave an example for yellow in the uploaded image example.

I think a VBA/Macro approach would be a better solution if you have tons of rows.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Excel VLOOKUP for multiple values

Outputting multiple VLookup values in Excel

excel vlookup multiple values and workbooks

Excel VLOOKUP to return blank if no values detected

How to return multiple values in an Array - Excel VBA

Vlookup to return multiple matching values in different rows

VLOOKUP with multiple return values Libre Office VB

VLOOKUP: Return multiple INDEX values in single VLOOKUP and SUM results

Excel vlookup multiple values and add duplicate rows

vlookup from name with multiple values excel

How to use VLOOKUP to return repeating lookup values?

Excel Vlookup with wildcards & multiple lookup values or Join in Excel Data Model

Excel Return Multiple Unique Values

How to return multiple values

Arrayformula Vlookup to return multiple values with one search_key

Excel - return multiple values for each of a list of values

VLOOKUP and IF in multiple excel sheets

Excel Vlookup Multiple columns

Excel VLOOKUP + SUMPRODUCT for multiple

Excel - vlookup with multiple conditions

Vlookup multiple columns in excel

VLOOKUP multiple values

How to vlookup to return multiple values using a "contains type" match, where the search string can appear anywhere in the lookup value

excel aggregate match return multiple values

How to do VLOOKUP based on multiple criteria and return the latest rows result?

How do i return multiple matching columns into 1 column with VLOOKUP

How to return multiple values ​with a function?

How to use a variable as one of the values in Excel VBA VLOOKUP

How to extract values from VLOOKUP via VBA in Excel?