|
Sub yy()
Dim Myre%, x%, aa$, k, t, i%
Dim d, xx, fsad, r1, n
Myre = [e65536].End(xlUp).Row
For x = 2 To Myre
aa = Cells(x, 5)
With Range("a:a")
Set r1 = .Find(aa)
fsad = r1.Address
xx = Cells(r1.Row, 2)
Set d = CreateObject("scripting.dictionary") '定义字典
If Not d.exists(xx) Then
d.Add xx, 1
Else
d(xx) = d(xx) + 1
End If
Do
Set r1 = .FindNext(r1)
n = r1.Address
If n <> fsad Then
xx = Cells(r1.Row, 2)
If Not d.exists(xx) Then
d.Add xx, 1
Else
d(xx) = d(xx) + 1
End If
End If
Loop While r1.Address <> fsad
End With
k = d.keys
t = d.items
For i = 0 To UBound(k)
Cells(x, 2 * i + 7) = k(i)
Cells(x, 2 * i + 8) = t(i)
Next i
Set d = Nothing
Next x
End Sub |
|