你觉得你说清除了么,让你身边的朋友或同时看看~~~~
VBA代码:
Option Explicit
Sub 找不同()
Dim db, i, x, st As Worksheet
Set db = CreateObject("Scripting.Dictionary")
'扫描shee1
Set st = Sheets("sheet1")
For i = 1 To st.UsedRange.Rows.Count
x = st.Cells(i, 1) & Chr(9) & st.Cells(i, 2)
db(x) = True
Next i
'扫描shee2
Set st = Sheets("sheet2")
For i = 1 To st.UsedRange.Rows.Count
x = st.Cells(i, 1) & Chr(9) & st.Cells(i, 2)
If db.Exists(x) Then
db(x) = False
Else
db(x) = True
End If
Next i
'生成shee3
Set st = Sheets("sheet3")
i = 1
For Each x In db.Keys
If db(x) Then
st.Cells(i, 1).Resize(1, 2) = Split(x, Chr(9))
i = i + 1
End If
Next x
End Sub
运行前后三个表的内容:
前四条相同,第五条不同,所以结果为第五条。