|
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim d(0 To 2) As Object
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- For k = 0 To 2
- Set d(k) = CreateObject("scripting.dictionary")
- Next
- vs = Array(Array(1, 3, 4), Array(1, 3), Array(3))
- With Worksheets("sheet1")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- .Range("l2:n" & r).ClearContents
- arr = .Range("a2:n" & r)
- For i = 1 To UBound(arr)
- For k = 0 To UBound(vs)
- xm = Empty
- For q = 0 To UBound(vs(k))
- xm = xm & arr(i, vs(k)(q))
- Next
- If Not d(k).exists(xm) Then
- Set d(k)(xm) = CreateObject("scripting.dictionary")
- End If
- d(k)(xm)(arr(i, 11)) = d(k)(xm)(arr(i, 11)) + 1
- Next
- Next
- For k = 0 To UBound(d)
- For Each aa In d(k).keys
- kk = d(k)(aa).keys
- nn = 1
- For q = 0 To UBound(kk)
- mm = Application.Large(kk, q + 1)
- ss = d(k)(aa)(mm)
- d(k)(aa)(mm) = nn
- nn = nn + ss
- Next
- Next
- Next
- For i = 1 To UBound(arr)
- For k = 0 To UBound(vs)
- xm = Empty
- For q = 0 To UBound(vs(k))
- xm = xm & arr(i, vs(k)(q))
- Next
- arr(i, k + 12) = d(k)(xm)(arr(i, 11))
- Next
- Next
- .Range("a2:n" & r) = arr
- End With
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|