简体   繁体   中英

How to reference a cell as table range when using vlookup

I have vlookups to pull specific data from a workbook and paste into a new workbook in the desired layout. The layout of the first workbook never changes however the name will change when i want to run this on a different file.

My current formula is =VLOOKUP(A3,[Workbook1.xlsx]Sheet1!$B$3:$XFD$7,2,FALSE)

I would really like it to reference A1 instead of Workbook1 so I could then just update the file name in A1 every time I want to analyse a different file. I should mention the Sheet name won't ever change.

I know you have to use INDIRECT but im unsure how it works. I did try =VLOOKUP(A3,INDIRECT(A1),$B$3:$XFD$7,2,FALSE) but then i'd too many arguments and when i removed the $B$3:$XFD$7 i lost the range i was searching in.

Thanks!

With INDIRECT you must create the whole string that denotes the range reference:

=VLOOKUP(A3,INDIRECT("'[" & A1 & "]Sheet1'!$B$3:$XFD$7"),2,FALSE)

One more note, that INDIRECT requires that the workbook be open to function, or will return an error.

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