41、[VBA入门到放弃笔记]字典应用:计数
作者:
叶知行 | 来源:发表于
2017-07-03 14:22 被阅读131次
字典常常用来进行计数
计数
Sub ggg()
Dim arr, d As Object, i As Long
arr = Range("a1:a" & Cells(Rows.Count, 1).End(xlUp).Row)'将数据放进数组
Set d = CreateObject("scripting.dictionary")'创建字典
For i = 1 To UBound(arr)'遍历数组元素
d(arr(i, 1)) = d(arr(i, 1)) + 1'对数组元素进行计数
Next
[d1].Resize(d.Count, 1) = Application.Transpose(d.keys)'输出数据
[e1].Resize(d.Count, 1) = Application.Transpose(d.items)
End Sub
结果
本文标题:41、[VBA入门到放弃笔记]字典应用:计数
本文链接:https://www.haomeiwen.com/subject/vzgacxtx.html
网友评论