Column 3:

add this code to a new module in the VB editor (Alt+F11)

Function aconcat(a As Variant, Optional sep As String = "") As String
' Harlan Grove, Mar 2002
Dim y As Variant

If TypeOf a Is Range Then
For Each y In a.Cells
aconcat = aconcat & y.Value & sep
Next y
ElseIf IsArray(a) Then
For Each y In a
aconcat = aconcat & y & sep
Next y
Else
aconcat = aconcat & a & sep
End If

aconcat = Left(aconcat, Len(aconcat) - Len(sep))
End Function
then assuming your data is in A1:B5, use:

=SUBSTITUTE(TRIM(aconcat(IF($B$1:$B$5=B1,$A$1:$A$5,"")," "))," ",",")

and confirm with CTRL+SHIFT+ENTER not just ENTER

copy down...

This separate entries with comma, you can change that... by changing the symbol between double quotes in last part of the formula.