A picture is worth a thousand words. Let\'s say in one sheet I have the following table:
I can see another approach as well. Add two columns Count and Key.
Add the formulas and expand:
C2 -> =COUNTIF($B$2:B2;B2) D2 -> =B2&"|"&C2 G2 -> =IFERROR(INDEX($A:$A;MATCH($F2&"|"&COLUMN(A1);$D:$D;0));"")