當前位置:成語大全網 - 新華字典 - 如何用vba查找某區域內相同重復數據,並統計數量?

如何用vba查找某區域內相同重復數據,並統計數量?

Sub test()

Dim arr, c, a&

arr = Intersect(Range("a:d"), ActiveSheet.UsedRange)

Set Zd = CreateObject("scripting.dictionary")

For Each c In arr

If c <> "" Then a = Zd(c): Zd(c) = a + 1

Next

[f2].Resize(Zd.Count) = Application.Transpose(Zd.keys)

[g2].Resize(Zd.Count) = Application.Transpose(Zd.items)

End Sub