See if this UDF (user defined function) does what you want...
Code:
Function GroupDates(GroupNum As Long) As String
Dim R As Long, Dates As Variant
Dates = Range(Cells(1, "B"), Cells(Rows.Count, "B").End(xlUp))
For R = UBound(Dates) To 1 Step -1
If Cells(R, "B").Value = GroupNum And Cells(R, "A") <> "" Then
GroupDates = GroupDates & ", " & Year(Cells(R, "A").Value)
End If
Next
GroupDates = Mid(GroupDates, 3)
End Function
HOW TO INSTALL UDFs
------------------------------------
If you are new to UDFs, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. You can now use
GroupDates just like it was a built-in Excel function. For example,
=GroupDates(B2)
If you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.