Rob said:
. . . I want to concatenate names that have the same integer
into the appropriate cell.
eg.
Worksheet 1.
John 1
Mary 3
Dave 1
Matt 3
Dean 1
Worksheet 2.
1 John, Dave, Dean
2
3 Mary, Matt
4
5
This sort of thing can't be done *generally* without some sort of add-in
function because Excel provides no array/range consolidating concatenation
operator or function.
The best solution involves downloading and installing Laurent Longre's
MOREFUNC.XLL add-in, available at
http://longre.free.fr/english/
It provides many useful functions, but its MCONCAT functions is needed for
this task. If the two-column range in the first worksheet were named Src,
and your list of numbers were in A1:A50 in the second worksheet, then enter
this array formula in cell B1 of the second worksheet.
=SUBSTITUTE(MCONCAT(IF(INDEX(Src,0,2)=A1,", "&INDEX(Src,0,1),"")),", ","",1)
Then fill down into B2:B50.
If you can't use add-ins, VBA would be next best. If you can't use VBA,
you're stuck with monster array formulas like (for B1)
=IF(COUNTIF(INDEX(Src,0,2),A1)<1,"",INDEX(Src,
MATCH(A1,INDEX(Src,0,2),0),1))
&IF(COUNTIF(INDEX(Src,0,2),A1)<2,"",", "&INDEX(Src,
SMALL(IF(INDEX(Src,0,2)=A1,ROW(Src)-CELL("Row",Src)+1,1000000),2),1))
&IF(COUNTIF(INDEX(Src,0,2),A1)<3,"",", "&INDEX(Src,
SMALL(IF(INDEX(Src,0,2)=A1,ROW(Src)-CELL("Row",Src)+1,1000000),3),1))
&IF(COUNTIF(INDEX(Src,0,2),A1)<4,"",", "&INDEX(Src,
SMALL(IF(INDEX(Src,0,2)=A1,ROW(Src)-CELL("Row",Src)+1,1000000),4),1))
&IF(COUNTIF(INDEX(Src,0,2),A1)<5,"",", "&INDEX(Src,
SMALL(IF(INDEX(Src,0,2)=A1,ROW(Src)-CELL("Row",Src)+1,1000000),5),1))
and this only pulls the first 5 corresponding names.