Sorry for the vague title. Let's start with an example. I have in columns A and B:

20351L	Viking Warrior Costume
20351M	Viking Warrior Costume
20351S	Viking Warrior Costume
20374L	Roman Warrior Costume
20374M	Roman Warrior Costume
I need to add column C of the sizes per costume and remove the duplicates.
20351	Viking Warrior Costume    L,M,S
20374	Roman Warrior Costume     L,M
As usual, I've tried to fix this myself. I know how to find, use and remove the last letter (the SIZE: S,M,L) from column A.
I know how to use conditional formatting to find unique or duplicate rows and then filter on that formatting.
I've found functions like "UNIQUE" and "TRANSPOSE" in other applications like Google Spreadsheets (it doesn't matter if this is done in Excel or not).

Where I'm stuck is finding a combination of functions for the following:

Where text in column B (OR the first 5 numbers of column A) of row 2 of is the same as row 1, cut or copy the last character of the text in row 2 of column A, into row 1 and concatenate with a comma.
Repeat while the next row is the same as row 1.