2

I'm looking to create a formula which outputs numerous values associated with an ID into just one cell. The number of values varies e.g. one ID may have 3 values associated with it, another may have just 1.

I know that if I were using VBA, I could use a loop to output all the values but I'm using just Excel in this example. All I have so far is a simple lookup which outputs just one value

=VLOOKUP(B2,'Customer Tape'!A:B,2,0)

(B2 is the cell; for Customer Tape column A is the ID, column B is the value)

Is there any way to get all of the values associated with the ID (e.g. values on other rows) and output it to the same cell?

enter image description here

Danny
  • 121
  • 8

1 Answers1

3

With older versions it is either vba or a helper column.

With the helper column put this in C2 and copy down:

=B2&IFERROR(","&VLOOKUP(A2,A3:C$1040000,3,FALSE),"")

enter image description here

Then you can use a normal VLOOKUP to return just the first result from column C:

=VLOOKUP(E2,A:C,3,FALSE)

enter image description here

If you want a vba version then see here:

EXCEL return range of values based on criteria

or here:

Merge values of column B based on common values on column A

Or here:

TextJoin UDF For Excel 2013


For Office 365 Excel no helper column needed:

=TEXTJOIN(",",TRUE,FILTER(B:B,A:A=E2,""))
Scott Craner
  • 148,073
  • 10
  • 49
  • 81