|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
请老师们帮忙看看附件的sheet4,汇总的数据在B57为什么会出现了数字2呢?语句哪里有缺陷呢?
Sub 字典统计不重复值()
Dim myr As Long, i As Long, arr
Dim d, k, t, sht As Worksheet
Set d = CreateObject("scripting.dictionary")
For Each sht In Sheets
If sht.Name <> "sheet4" Then
myr = sht.Range("a1048576").End(xlUp).Row
arr = sht.Range("a2:a" & myr)
For i = 1 To UBound(arr)
d(arr(i, 1)) = d(arr(i, 1)) + 1
Next
End If
Next
k = d.keys
t = d.ITEMS
Sheet4.[a3].Resize(d.Count, 1) = Application.Transpose(k)
Sheet4.[B3].Resize(d.Count, 1) = Application.Transpose(t)
Set d = Nothing
End Sub
|
|