|
发表于 2013-7-28 00:20
|
显示全部楼层
本楼为最佳答案
- Option Explicit
- Dim A, B, C, d, i, j, s
- Sub test()
- A = Sheet1.Range("a1").CurrentRegion
- B = Sheet2.Range("a1").CurrentRegion
- Set d = CreateObject("scripting.dictionary")
- test2
- test3 B, A, "辍学"
- test3 A, B, "转入"
- End Sub
- Sub test2()
- ReDim C(1 To 10 ^ 4, 1 To UBound(A, 2))
- For j = 1 To UBound(C, 2)
- C(1, j) = A(4, j)
- Next j
- End Sub
- Sub test3(A, B, str)
- d.RemoveAll
- For i = 5 To UBound(A)
- d(A(i, 2)) = ""
- Next i
- s = 1
- For i = 5 To UBound(B)
- If d.exists(B(i, 2)) = False Then
- s = s + 1
- For j = 1 To UBound(B, 2)
- C(s, j) = B(i, j)
- Next j
- End If
- Next i
- With Sheets(str)
- .Cells.ClearContents
- .Range("a1").Resize(s, j - 1) = C
- End With
- End Sub
复制代码
较复杂的两表比对2.rar
(16.69 KB, 下载次数: 18)
|
|