|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub ddddd()
Dim arr, brr, i, m, n, a, b, crr, k, drr()
Set d = CreateObject("scripting.dictionary")
arr = Range("a2:b" & Cells(Rows.Count, 1).End(xlUp).Row)
For i = 1 To UBound(arr)
d(arr(i, 1)) = d(arr(i, 1)) + arr(i, 2)
Next
brr = Application.Transpose(Array(d.keys, d.items))
For m = 1 To UBound(brr)
For n = m + 1 To UBound(brr)
If brr(m, 2) < brr(n, 2) Then
a = brr(m, 1): b = brr(m, 2)
brr(m, 1) = brr(n, 1): brr(m, 2) = brr(n, 2)
brr(n, 1) = a: brr(n, 2) = b
End If
Next
Next
d.RemoveAll
For i = 1 To UBound(brr)
d(brr(i, 2)) = brr(i, 2)
Next
crr = d.keys
For i = 1 To UBound(brr)
n = 0
p = p + 1
ReDim Preserve drr(1 To 3, 1 To i)
For j = 0 To UBound(crr)
If brr(i, 2) <= crr(j) Then n = n + 1
Next
drr(1, i) = n
drr(2, i) = brr(i, 1)
drr(3, i) = brr(i, 2)
Next
Range("h:j").ClearContents
Cells(1, "h").Resize(1, 3) = Array("求和后名次", "款号", "求和数量")
Cells(2, "h").Resize(p, 3) = Application.Transpose(drr)
End Sub
重复数据求和排名引用.zip
(290.32 KB, 下载次数: 6)
|
|