|
求教老师,
使用VBA将表格中的数据sheet2的行数据比对sheet1中数据,输出不在sheet1中的数据到...
http://club.excelhome.net/thread-1369447-1-1.html
(出处: ExcelHome技术论坛)
我自己写的代码不知道哪里有问题,请教!
Sub test()
Dim arr, arr1, drow, d As Object, i%, j%, k%
arr = Sheet1.[a1].CurrentRegion
arr1 = Sheet2.[a1].CurrentRegion
Set d = CreateObject("scripting.dictionary")
For k = 2 To UBound(arr)
d(arr(k, 1)) = ""
Next
For i = 2 To UBound(arr1, 1)
For j = 2 To UBound(arr1, 2)
If d.exists(arr1(i, j)) Then
d.Remove (arr1(i, j))
Else
d(arr1(i, j)) = ""
'Exit For
End If
Next
Next
drow = Sheet2.[a65536].End(xlUp).Row
Sheet3.Range("B2").Resize(drow-1, d.Count) = d.keys
End Sub
|
|