我正在工作簿「文件」。然後,我打開另一個用於查找數據的工作簿(Masterfile)。VBA查找與定義的範圍和從其他工作簿中的文件
Workbooks.Open FileName:=Path & Masterfile
lRowMasterfile = Cells(Rows.Count, "A").End(xlUp).Row
SelectionMasterfile = Range("A1").CurrentRegion.Address
Workbooks(File).Activate
Range("K2").FormulaR1C1 = "=VLOOKUP(RC[-1],'" & Masterfile"' & ! & SelectionMasterfile,1, FALSE)"
Range("K2").AutoFill Destination:=Range("K2:K" & lRowFile)
Workbooks(Masterfile).Close
我定義了Masterfile和Range來在其他文檔中使用它,但不幸的是它不起作用。任何人都可以幫忙嗎?
我猜這是你的代碼的一部分,因爲只是做一個表單上的查找?如果是這樣,請嘗試使用find。此外,限定您的範圍。 – findwindow