简体   繁体   中英

VLookup in excel file in VBA in Access

In VBA, I know how to import data from an Excel File into Access using a define range of cells from the file ( using DoCmd.TransferSpreadsheet acImport)

However if lines are inserted in the excel files my range address is wrong. So I would like to lookup a keyword in my excel file first that would give me a row number so I can define a range based on the position of the keyword in the file. Something like
I tried to use

Application.WorksheetFunction.VLookup

But it did not work

Thank you

use match function to return Row Number

X= Application.match("Keyword",worksheets("Worksheetname").Columns(column number),0)

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