第1个回答 2011-05-12
可以试试 vba
Sub a()
Application.ScreenUpdating = False
Dim dic As Object, i, j, arr, r
Set dic = CreateObject("Scripting.Dictionary")
arr = Range("a1:a" & Range("a65536").End(xlUp).Row)
For i = 1 To UBound(arr)
r = dic(arr(i, 1))
Next
Range("c1").Resize(dic.Count, 1) = Application.Transpose(dic.Keys)
Columns("d:d").Select
Selection.NumberFormatLocal = "@"
For j = 1 To Range("c65536").End(xlUp).Row
For i = 1 To UBound(arr)
If Cells(i, 1).Value = Cells(j, 3).Value Then
If Cells(j, 4).Value = "" Then
Cells(j, 4).Value = Cells(i, 2).Value
Else
Cells(j, 4).Value = Cells(j, 4).Value & "," & Cells(i, 2).Value
End If
End If
Next i
Next j
Application.ScreenUpdating = True
End Sub
最终结果 在 CD 列