- Sub yy() 'hlly888
- Range("i2:k65536").ClearContents
- Application.ScreenUpdating = False
- Dim dc As Object, arr, brr(), i&, w, s&, a, c, crr(1 To 6, 1 To 5)
- Set dc = CreateObject("scripting.dictionary")
- arr = [a1].CurrentRegion
- ReDim brr(1 To UBound(arr), 1 To 5)
-
- For i = 2 To UBound(arr)
- a = arr(i, 1) & arr(i, 2)
- w = dc(a)
- If w = "" Then
- s = s + 1: dc(a) = s
- brr(s, 1) = arr(i, 1)
- brr(s, 2) = arr(i, 2)
- brr(s, 3) = arr(i, 3)
- brr(s, 4) = arr(i, 5)
- brr(s, 5) = brr(s, 4) / brr(s, 3)
- Else
- brr(w, 3) = brr(w, 3) + arr(i, 3)
- brr(w, 4) = brr(w, 4) + arr(i, 5)
- brr(w, 5) = brr(w, 4) / brr(w, 3)
- End If
- Next
- For i = 1 To s
- If brr(i, 5) < 1000 Then c = 1
- If brr(i, 5) >= 1000 And brr(i, 5) < 3000 Then c = 2
- If brr(i, 5) >= 3000 And brr(i, 5) < 5000 Then c = 3
- If brr(i, 5) >= 5000 And brr(i, 5) < 10000 Then c = 4
- If brr(i, 5) >= 10000 Then c = 5
- crr(c, 1) = crr(c, 1) + 1: crr(c, 2) = crr(c, 2) + brr(i, 3): crr(c, 3) = crr(c, 3) + brr(i, 4)
- crr(6, 2) = crr(6, 2) + brr(i, 3): crr(6, 3) = crr(6, 3) + brr(i, 4)
- Next
- crr(6, 1) = s
- [i2].Resize(6, 3) = crr
- Application.ScreenUpdating = True
- End Sub
复制代码 |