修改了一些
Public Sub eee()
ReDim ar(1 To 4, 1 To Sheet1.UsedRange.Rows.Count)
Set range1 = Workbooks("2.xls").Sheets(1).UsedRange
On Error Resume Next
For Each x In Range([a2], [a2].End(xlDown))
rel = Application.Match(x, range1, 0)
n = n + 1
ar(1, n) = IIf(Err.Number = 0, Application.VLookup(x, range1, 13, 0), "")
ar(2, n) = IIf(Err.Number = 0, Application.VLookup(x, range1, 14, 0), "")
ar(3, n) = IIf(Err.Number = 0, Application.VLookup(x, range1, 15, 0), "")
ar(4, n) = IIf(Err.Number = 0, Application.VLookup(x, range1, 16, 0), "")
Err.Number = 0
Next
[w2].Resize([a2].End(xlDown).Row - 1, 4).ClearContents
[w2].Resize([a2].End(xlDown).Row - 1, 4) = Application.Transpose(ar)
End Sub |