|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub yy()
- Dim Arr, i&, Myr&, Myc%, Arr2, Arr3, col%
- Dim d, k, t, m&, n1&, n2&, j&, zm$
- Set d = CreateObject("Scripting.Dictionary")
- Application.ScreenUpdating = False
- Sheet3.Activate
- [a6:s500].Clear
- zm = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- Myc = [iv2].End(xlToLeft).Column
- Arr3 = Range("a2").Resize(1, Myc)
- Arr = Sheet1.[a1].CurrentRegion
- For i = 2 To UBound(Arr)
- If Arr(i, 1) <> "" Then d(Arr(i, 1)) = i
- Next
- Arr2 = Sheet2.[a1].CurrentRegion
- n1 = 5: n2 = 5
- For i = 2 To UBound(Arr2)
- If d.exists(Arr2(i, 1)) Then
- m = d(Arr2(i, 1))
- For j = 1 To UBound(Arr3, 2)
- col = InStr(zm, Arr3(1, j))
- If Arr2(m, col) <> Arr(m, col) Then
- n1 = n1 + 1
- Cells(n1, 1).Resize(1, UBound(Arr, 2)) = Application.Index(Arr, m, 0)
- n2 = n2 + 1
- Cells(n2, 11).Resize(1, UBound(Arr2, 2)) = Application.Index(Arr2, i, 0)
- End If
- Next
- ElseIf Arr2(i, 1) <> "" Then
- n2 = n2 + 1
- Cells(n2, 11).Resize(1, UBound(Arr2, 2)) = Application.Index(Arr2, i, 0)
- End If
- Next
- [a6].Resize(n1 - 5, 9).Borders.LineStyle = 1
- [k6].Resize(n2 - 5, 9).Borders.LineStyle = 1
- Set d = Nothing
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|