Sub BuildTable()
Application.ScreenUpdating = False
With Range("C1:D" & Range("A" & Rows.Count).End(xlUp).Row)
.Columns(1).Formula = "=MATCH(A1,A$1:A1,0)&""#""&A1&IF(COUNTIF(A$1:A1,A1)=1,"""",""#"")"
.Columns(2).Formula = "=B1"
.Value = .Value
.Sort Key1:=.Cells(1, 1), Order1:=xlAscending, Header:=xlNo, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
.Replace What:="*#*#", Replacement:="", SearchFormat:=False, ReplaceFormat:=False
.Replace What:="*#", Replacement:="", LookAt:=xlPart, SearchFormat:=False, ReplaceFormat:=False
End With
Application.ScreenUpdating = True
End Sub