简体   繁体   中英

Excel VBA Vlookup different workbook without the the file opened

I'm trying to write a macro with Excle VBA that Vlookup a different workbook without opening the file, however, the system highlighted the "'" before C:,and showed Compile error "Expected: expression". I am trying get this done without using it in a string "=Vlookup .... etc"."

For j = 2 To lastRow
With Worksheets("ABC")
.Range("K" & j).Value = Application.WorksheetFunction.VLookup(.Range("B" & j),'C:\Sales\John''s file\[Sales.xlsx]Weekly'!$A:$C,3,1)
Next j

'C:\\ Sales \\ John's file [Sales.xlsx] Weekly'!$ A:$ C必须用双引号括起来,因为它是您要传递的字符串,而且您可能只想在john''s上使用单引号john''s

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM