Option Explicit
Sub ABC()
Dim sArr(), res(), sRow&, i&, k&, j&, tmp$, sCol&
With Sheets("Sheet1")
res = .Range("C3", .Range("D" & Rows.Count).End(xlUp)).Value
sRow = UBound(res)
.Range("C3").Resize(sRow, 2).Sort .Range("C3"), 1, .Range("D3"), , 1, Header:=xlNo
sArr = .Range("C3").Resize(sRow, 2).Value
.Range("C3").Resize(sRow, 2).Value = res
End With
ReDim res(1 To sRow, 1 To sRow)
For i = 1 To sRow
If tmp <> sArr(i, 1) Then
If sCol < j Then sCol = j
tmp = sArr(i, 1)
k = k + 1: j = 1
res(k, 1) = tmp
End If
j = j + 1
res(k, j) = sArr(i, 2)
Next i
Sheet1.Range("H7").Resize(k, sCol) = res
End Sub