|
楼主 |
发表于 2017-9-17 12:48
|
显示全部楼层
我自己写了代码但是不知道错在哪里
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, d.Count) = d.keys
End Sub
|
|