|
如题,初学宏,学习蓝桥版主的字典用法,自己试了一个算重复个数的例子,但展现不全,不知道是哪里错了,代码如下,求各位老师帮助:
Sub cfz()
Dim i&, Arr
Dim d, k, t
Set d = CreateObject("Scripting.Dictionary")
Sheets("原始数据").Activate
Arr = Sheets("原始数据").Range("A2", "B" & ([A1000000].End(xlUp).Row))
For i = 1 To UBound(Arr)
d(Arr(i, 1)) = d(Arr(i, 1)) + 1
Next
k = d.keys
t = d.items
Sheets("sheet3").Activate
[a2].Resize(d.Count, 1) = Application.Transpose(k)
[b2].Resize(d.Count, 1) = Application.Transpose(t)
[a1].Resize(1, 2) = Array("公司名称", "重复个数")
Set d = Nothing
End Sub
|
|