|
楼主 |
发表于 2014-1-25 14:54
|
显示全部楼层
- Sub test()
- Dim arr, brr, d, i&, j&, zf$, crr(), drr()
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- arr = Range("a1").CurrentRegion
- MyRow = UBound(arr)
- ReDim crr(1 To 100, 1 To 11): ReDim drr(1 To 100, 1 To 11)
- For i = 3 To 13
- crr(1, i - 2) = arr(3, i)
- Next
- m = 1
- For i = 4 To MyRow
- If Not d.Exists(arr(i, 3)) Then
- m = m + 1
- d(arr(i, 3)) = m
- crr(m, 1) = arr(i, 3)
- End If
- Next
- For j = 4 To 13
- Cells(3, 3).Resize(MyRow - 2).Copy [p3]
- Cells(3, j).Resize(MyRow - 2).Copy [q3]
- Range("p3:q" & MyRow).Sort Key1:=Range("q3"), Order1:=xlDescending, Header:=xlGuess
- arr = Range("p3:q" & (MyRow - 5))
- For i = 2 To UBound(arr)
- crr(d(arr(i, 1)), j - 2) = crr(d(arr(i, 1)), j - 2) + arr(i, 2)
- drr(d(arr(i, 1)), j - 2) = drr(d(arr(i, 1)), j - 2) + 1
- Next
- Next
- For i = 2 To m
- For j = 2 To 11
- crr(i, j) = crr(i, j) / drr(i, j)
- Next
- Next
- [p:ac].Clear
- Application.ScreenUpdating = True
- [s3].Resize(m, 11) = crr
- End Sub
复制代码 |
|