Now suppose your data is in columns A and B, starting from the first row.
Now, enter the data with the initial serial number of 1 in C 1, D 1, etc. That is, first enter "1 A B C" manually in your example.
Enter the formula in cell C2:
=IF($A2=$A 1,"",A2)
Drag down to the end of the data.
Enter the formula for D2:
=IF($A2=$A 1,"",IF(ISERR(INDIRECT(" b " & amp; IF (indirect ("a" & ROW()+COLUMN(A2)- 1) = $ a2, row ()+column (a2)-1,""), "",indirect ("b"&; IF (indirect ("a"& ROW()+COLUMN(A2)- 1) = $ A2, row ()+column (A2)-1,""))
Drag to the right (be careful to drag to the right until there are enough columns to ensure that the cells behind each row of data cannot drag data), and then drag down to the bottom of the data.