我乱写的,没有数据我也不知道写得对不对 Sub test() Workbooks.Open ("E:\工作文件夹\记录\无效IOSS号.xlsx") Set sht = Workbooks("无效IOSS号.xlsx").Sheets("Sheet1") arr = sht.Range("A1:A" & [a65536].End(3).Row) Workbooks("无效IOSS号.xlsx").Close False Set sht1 = ActiveSheet arr1 = sht1.Range("E1:F" & [E65536].End(3).Row) For i = 3 To UBound(arr1) For j = 1 To UBound(arr) If arr1(i, 1) = arr(j, 1) Then arr1(i, 2) = arr(j, 1) Exit For End If Next Next sht1.Range("E1:F" & [E65536].End(3).Row) = arr1 End Sub
Sub test() dim wb as worksheet dim wsA as worksheet,wsB as worksheet dim RowA application.EnableEvents = false application.ScreenUpdating = false set wb = Workbooks.Open ("E:\工作文件夹\记录\无效IOSS号.xlsx") Set wsa = thisWorkbook.Sheets("Sheet1") set wsb = activesheet RowA=wsb.range("E" & wsb.rows.count).end(xlup).row with wsb .range("F3“).Formula = "VLookUP(E3,'" & wb.fullpath & "'[" & wsa.name & "!]$A:$A,1,0)" .range("F3").autofill .range("F3:F" & rowa) end with wb.close false application.EnableEvents = True application.ScreenUpdating = True End Sub