INDIRECT Function

jeffmoseler

Well-known Member
Joined
Jul 16, 2004
Messages
540
I found a new handy function that allows me to write a formula that keeps the sheet name of the formula dynamic. It's pretty cool except that I barely understand how it works!

So I have a formula that looks like this: =VLOOKUP(B3,'[2019 BOB Goal Calculation.xlsx]2019'!$C$8:$D$20,2,0)

I would like to replace the Sheet reference (2019) with a dynamic year number so next year I don't have to change all the formulas. But I'm not sure how to integrate the two.

=VLOOKUP(B3,'[2019 BOB Goal Calculation.xlsx](INDIRECT($D$2&'"!$C$8:$D$20")),2,0)

I keep getting a syntax error. I'm hoping this is obvious to someone and they can help me figure out what the correct syntax should be.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
It would be:

=VLOOKUP(B3,INDIRECT("'[2019 BOB Goal Calculation.xlsx]"&$D$2&"'!$C$8:$D$20"),2,0)
 
Upvote 0
Indirect provides a reference based on text string.
A reference consists of filename, sheet name and range address.
It either explicit or indirect.This goes to all parts of the reference.
You can't mix direct filename with indirect sheet and name. That's why you get an error.
However I believe you can't use INDIRECT on closed workbooks. So for such a formula to work the referred workbook must also be opened.
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,380
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top