|
Sub qs()
Dim arr, i, dic
Set dic = CreateObject("scripting.dictionary")
arr = Sheet1.Range("a1").CurrentRegion.Value
ReDim brr(1 To UBound(arr), 1 To 3)
For i = 2 To UBound(arr)
s = arr(i, 3)
If Not dic.exists(s) Then
m = m + 1
dic(s) = m
brr(m, 1) = s
brr(m, 2) = arr(i, 1)
brr(m, 3) = 1
Else
rw = dic(s)
brr(rw, 3) = brr(rw, 3) + 1
If VBA.InStr(brr(rw, 2), arr(i, 1)) = 0 Then
brr(rw, 2) = brr(rw, 2) & "|" & arr(i, 1)
End If
End If
Next
For i = 1 To m
brr(i, 2) = UBound(Split(brr(i, 2), "|")) + 1
Next
Sheet2.Range("a2").Resize(m, 3) = brr
End Sub
|
|