Copy & Traspose Paste Loop

I have a large table of data with a lot of duplicate information ie column 1 has “ID1” then column 2 “ID2” and ID 1 is the parent ID then ID2 the child ID.

In short, I want to copy everything in column 2 that has duplicate parent IDs and transpose it I to the top row for the first duplicate.

The problem being, there are different amounts of child IDs for each parent ID. Some may have 12,some 25.

I was thinking a Do Until Loop, but I don’t know how to write it.