|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub 字典构建链处理() '//2024.7.27
- ls = 6
- Set d = CreateObject("Scripting.Dictionary")
- Set D1 = CreateObject("Scripting.Dictionary")
- r = Cells(Rows.Count, 1).End(3).Row
- arr = [a1].Resize(r, 2)
- For i = 2 To UBound(arr)
- If Not D1.Exists(arr(i, 1)) Then
- d(arr(i, 1)) = i
- D1(arr(i, 1)) = i
- Else
- arr(d(arr(i, 1)), 1) = i
- d(arr(i, 1)) = i
- End If
- Next i
- i = 0: Range("d1").CurrentRegion.Offset(1, 0).Clear
- ReDim brr(1 To UBound(arr), 0 To ls)
- For Each dk In D1.Keys
- i = i + 1: j = 0: i1 = i
- brr(i, 0) = dk: k = D1(dk):
- Do
- j = j + 1: If j > ls Then i = i + 1: j = 1
- brr(i, j) = arr(k, 2): k = arr(k, 1)
- Loop Until k = dk
- Range(Cells(i1 + 1, "D"), Cells(i + 1, "D")).Merge
- Next dk
- [D2].Resize(i, ls + 1) = brr
- Set d = Nothing
- Set D1 = Nothing
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|