|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- rivate Sub CommandButton1_Click()
- Dim arr, n&, d, drr, i&
- n = [a65536].End(xlUp).Row - 1
- arr = [a2].Resize(n)
- ReDim drr(1 To n, 1 To 2)
- Set d = CreateObject("scripting.dictionary")
- For i = 1 To n
- If Not d.exists(arr(i, 1)) Then d(arr(i, 1)) = d.Count + 1 '字典item存key序号,利用数组运算,确保使用最少字典
- drr(d(arr(i, 1)), 1) = drr(d(arr(i, 1)), 1) + 1 'drr(,1)对key出现次数计数
- drr(d(arr(i, 1)), 2) = IIf(drr(d(arr(i, 1)), 1) > 1, drr(d(arr(i, 1)), 2) & ",", "") & i + 1 '重复值行次汇集到drr
- Next
- [p2].Resize(d.Count) = Application.Transpose(d.keys)
- [q2].Resize(n, 2) = drr
- End Sub
复制代码 |
|