|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
字典经典用法之一- Sub ykcbf() '//2024.11.29
- Set d = CreateObject("Scripting.Dictionary")
- r = Cells(Rows.Count, 1).End(3).Row
- arr = [a1].Resize(r, 2)
- ReDim brr(1 To r, 1 To 2)
- For i = 1 To UBound(arr)
- s = arr(i, 1)
- If Not d.exists(s) Then
- m = m + 1
- d(s) = m
- brr(m, 1) = s
- End If
- s = arr(i, 1) & "-" & arr(i, 2)
- If Not d.exists(s) Then
- n = n + 1
- d(s) = n
- brr(n, 2) = s
- End If
- Next
- Max = IIf(m < n, n, m)
- [d2].Resize(Max, 2) = brr
- Set d = Nothing
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|