|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Public Sub Test()
- Dim i&, Myr&, Arr
- Dim d, k, t
- Set d = CreateObject("Scripting.Dictionary")
- Myr = Sheet1.[a65536].End(xlUp).Row
- Arr = Sheet1.Range("a1:g" & Myr)
- For i = 2 To UBound(Arr)
- d(Arr(i, 3)) = d(Arr(i, 3)) + 1
- Next
- k = d.keys
- t = d.items
- 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
复制代码 在学习蓝桥大神的字典的教程的时候,对第八行代码不是很理解,d(Arr(i,3))代表的是Arr(i,3)对应的items,但是并没有字典并没有写入,还是说如果不写入items那么它的items默认就是为空(看了第二个实例感觉应该是这样的,但是网上搜也没搜到相关解释)
|
|