|
Sub test()
Dim d As Object
Set d = CreateObject("scripting.dictionary")
ar = Sheets("ERP").Range("a1:a" & Sheets("ERP").Cells(Rows.Count, 1).End(xlUp).Row)
br = Sheets("Bank").Range("b1:b" & Sheets("Bank").Cells(Rows.Count, 2).End(xlUp).Row) '''
Dim arr()
ReDim arr(1 To UBound(ar), 1 To 1)
For i = 2 To UBound(ar)
If Trim(ar(i, 1)) <> "" Then
d(ar(i, 1)) = ""
End If
Next
For i = 2 To UBound(br)
If Trim(br(i, 1)) <> "" Then
If Not d.exists(Trim(br(i, 1))) Then
n = n + 1
arr(n, 1) = br(i, 1)
End If
End If
Next i
If n = "" Then
MsgBox "没有不一致的数据!": Exit Sub
Else
Sheets("Bank").[a1].Resize(n, 1) = arr
MsgBox "ERP中无“" & n & "”,已经添加,数据已写到a列"
End If
Set d = Nothing
End Sub
|
|