|
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim d As Object
- Set d = CreateObject("scripting.dictionary")
- With Worksheets("原表")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a2:ac" & r)
- For j = 7 To UBound(arr, 2) - 2 Step 2
- d.RemoveAll
- For i = 1 To UBound(arr)
- If Len(arr(i, j)) <> 0 Then
- If Not d.exists(arr(i, 1)) Then
- Set d(arr(i, 1)) = CreateObject("scripting.dictionary")
- End If
- d(arr(i, 1))(arr(i, j)) = d(arr(i, 1))(arr(i, j)) + 1
- End If
- Next
- For Each aa In d.keys
- nn = 1
- kk = d(aa).keys
- For k = 0 To UBound(kk)
- mm = Application.Large(kk, k + 1)
- ss = d(aa)(mm)
- d(aa)(mm) = nn
- nn = nn + ss
- Next
- For i = 1 To UBound(arr)
- arr(i, j + 1) = ""
- If Len(arr(i, j)) <> 0 Then
- arr(i, j + 1) = d(arr(i, 1))(arr(i, j))
- End If
- Next
- Next
- Next
- d.RemoveAll
- For i = 1 To UBound(arr)
- If Len(arr(i, 27)) <> 0 Then
- If Not d.exists(arr(i, 1)) Then
- Set d(arr(i, 1)) = CreateObject("scripting.dictionary")
- End If
- If Not d(arr(i, 1)).exists(arr(i, 2)) Then
- Set d(arr(i, 1))(arr(i, 2)) = CreateObject("scripting.dictionary")
- End If
- d(arr(i, 1))(arr(i, 2))(arr(i, 27)) = d(arr(i, 1))(arr(i, 2))(arr(i, 27)) + 1
- End If
- Next
- For Each aa In d.keys
- For Each bb In d(aa).keys
- nn = 1
- kk = d(aa)(bb).keys
- For k = 0 To UBound(kk)
- mm = Application.Large(kk, k + 1)
- ss = d(aa)(bb)(mm)
- d(aa)(bb)(mm) = nn
- nn = nn + ss
- Next
- Next
- Next
- For i = 1 To UBound(arr)
- If Len(arr(i, 27)) <> 0 Then
- arr(i, 29) = d(arr(i, 1))(arr(i, 2))(arr(i, 27))
- End If
- Next
- .Range("a2").Resize(UBound(arr), UBound(arr, 2)) = arr
- End With
- End Sub
复制代码 |
评分
-
2
查看全部评分
-
|