Assuming that:
1. You only change the date in the filename (ex. only the 08302018 part)
2. This date is always formatted as mmddyyyy
3. This date is always =TODAY()-8
4. All other details remain the same (e.g worksheet name, source file being in the same folder as destination file, return values under column C, etc...)
Then you can use the INDIRECT
function to automatically change that date within the formula:
=VLOOKUP(B2,INDIRECT("'[Approved Contractors "&TEXT(TODAY()-8,"mmddyyyy")&".xlsx]Contractor with key'!$B$2:$C$99999"),2,0)
However, I noticed that your example goes against the 3rd assumption, and that instead of referencing it to TODAY()-8
, you want to reference it to the THURSDAY
date of that current week. In that case, you just need to change the reference date in the above formula. Kindly consider the formula below:
=VLOOKUP(B2,INDIRECT("'[Approved Contractors "&TEXT(TODAY()-WEEKDAY(TODAY())+5,"mmddyyyy")&".xlsx]Contractor with key'!$B$2:$C$99999"),2,0)
To clarify, what this does is it changes the date in reference filename within the formula to the THURSDAY
date of the current week. So when you run it in your file today (9/15/2018), the reference filename should be "Approved Contractors 09132018.xlsx".
If this returns an error, it may mean the supposed reference file was incorrectly named. In this case using an IFERROR
function would alert us to check the reference filename. When an error does happen, the following formula would display "Please check reference filename":
=IFERROR(VLOOKUP(B2,INDIRECT("'[Approved Contractors "&TEXT(TODAY()-WEEKDAY(TODAY())+5,"mmddyyyy")&".xlsx]Contractor with key'!$B$2:$C$99999"),2,0),"Please check reference filename")