字典常常用来进行计数
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