This could be a formula alternative:
Try this, in C2 enter:
=1+COUNTIF(data!A:A,B2)+C1-(COUNTIF(data!A:A,B2)>0)
copied down to bottom
In D2 enter:
in E2 enter:
=IF(ROWS($A$2:$A2)>$D$2,"",INDEX($B$2:$B$84,MIN(IF(ROWS(A$2:A2)<=$C$2:$C$84,ROW($C$2:$C$84)-ROW($C$2)+1))))
confirmed with CTRL+SHIFT+ENTER and copied down beyond the bottom until you get blanks.
in F2 enter:
=IFERROR(INDEX(data!$D$2:$D$6,SMALL(IF(data!$A$2:$A$6=E2,ROW(data!$A$2:$A$6)-ROW(data!$A$2)+1),COUNTIF(E$2:E2,E2))),"")
adjust ranges for data! sheet and confirmed with CTRL+SHIFT+ENTER and copied down
You can then copy and Paste special >> Values over the original 2 columns if desired and remove these formula columns.
Bookmarks