|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
学习一下字典,打扰了
Sub test()
arr = [a1].CurrentRegion
Set d = CreateObject("scripting.dictionary")
ReDim brr(1 To UBound(arr), 1 To 2)
For i = 2 To UBound(arr)
If Not d.exists(arr(i, 1)) Then
m = m + 1
brr(m, 1) = arr(i, 1)
brr(m, 2) = arr(i, 2)
d(arr(i, 1)) = m
Else
r = d(arr(i, 1))
brr(r, 2) = brr(r, 2) + arr(i, 2)
End If
Next
For i = 1 To UBound(brr)
If brr(i, 2) >= 1000 Then
n = n + 1
brr(n, 1) = brr(i, 1)
brr(n, 2) = brr(i, 2)
End If
Next
[d2].Resize(n, 2) = brr
End Sub |
评分
-
2
查看全部评分
-
|