|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 zhangcheng6688 于 2024-4-4 09:38 编辑
学习一下字典,打扰
Sub test()
arr = [a2].CurrentRegion
ReDim brr(1 To UBound(arr), 1 To 2)
Set d = CreateObject("scripting.dictionary")
For i = 1 To UBound(arr)
s = arr(i, 1)
s1 = arr(i, 2)
If Not d.exists(s & "|" & s1) Then
d(s) = d(s) + 1
d(s & "|" & s1) = ""
End If
Next
For Each k In d.keys
If InStr(k, "|") = 0 Then
m = m + 1
brr(m, 1) = k
brr(m, 2) = d(k)
End If
Next
[e2].Resize(m, 2) = brr
End Sub |
评分
-
1
查看全部评分
-
|