|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
学习一下字典,打扰了
Sub test()
arr = [b1].CurrentRegion
Set d = CreateObject("scripting.dictionary")
For i = 2 To UBound(arr)
If Not d.exists(arr(i, 1)) Then
Set d(arr(i, 1)) = CreateObject("scripting.dictionary")
End If
If Not d(arr(i, 1)).exists(arr(i, 2)) Then
d(arr(i, 1))(arr(i, 2)) = d(arr(i, 1)).Count + 1
arr(i, 3) = d(arr(i, 1))(arr(i, 2))
Else
arr(i, 3) = d(arr(i, 1))(arr(i, 2))
End If
Next
Columns(4).NumberFormat = "000"
[b1].CurrentRegion = arr
End Sub |
评分
-
1
查看全部评分
-
|