|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
还有2个地方抄错:
1,Columns("A:A").NumberFormatLocal = "@" 在@后面多了个中文的 ”;
2,以前的附件有Sheet6,现在变成了Sheet7了。现在改为“对比结果”
- Sub lqxs()
- Dim Arr, i&, Brr(1 To 1000, 1 To 3), n%, ks, x$, y$, kk, tt, ii%
- Dim d, k, t, m%
- Set d = CreateObject("Scripting.Dictionary")
- Dim Sht As Worksheet
- For Each Sht In Sheets
- If Sht.Name <> "对比结果" Then
- Arr = Sht.[a1].CurrentRegion
- y = Sht.Name
- For i = 2 To UBound(Arr)
- x = Arr(i, 1) & "|" & Arr(i, 2)
- If d.exists(x) = False Then Set d(x) = CreateObject("Scripting.Dictionary")
- d(x)(y) = Arr(i, 3)
- Next
- End If
- Next
- Sheets("对比结果").Activate
- [a:c].ClearContents
- Columns("A:A").NumberFormatLocal = "@"
- k = d.keys: t = d.items
- For i = 0 To UBound(k)
- bb = Split(k(i), "|")
- kk = t(i).keys: tt = t(i).items
- ks = tt(0): n = 1: ss = ks
- For ii = 1 To UBound(tt)
- If tt(ii) >= ks Then
- n = n + 1
- ks = tt(ii): ss = ss & "-" & ks
- Else
- GoTo 100
- End If
- Next
- m = m + 1
- Brr(m, 1) = bb(0): Brr(m, 2) = bb(1): Brr(m, 3) = ss
- 100:
- Next
- If m > O Then [a2].Resize(m, 3) = Brr
- End Sub
复制代码 |
|