reference date in cell for file name in vlookup - excel-formula

I have a vlookup that references the prior month end file on a shared drive. These files are saved with the date in the file name as mmddyyyy.
=VLOOKUP([#[DealerCode]],'\\mypath\[Performance_07312017.xlsm]SheetName'!$B:$K,10,FALSE)
The formula must be manually changed at the beginning of each month. I want to have the formula look up from the previous months file by referencing the current date in C1. I've tried the following, but I get #VALUE.
=VLOOKUP([#[Dealer Code]],CONCATENATE("'\\mypath\[Performance_",TEXT(EOMONTH($C$1,-1),"mmddyyyy"),".xlsm]SheetName'!$B:$K"),10,FALSE)
I want to leave the month end files closed, so I don't think INDIRECT is an option.
It seems like this should be simple, but I'm stumped. Thanks in advance for any guidance y'all can give.

The only solution short of VBA is with Indirect, but as you already mentioned, it does not work with closed files. There is a free add-in called Morefunc.dll, which has a function called IndirectEXT, which works with closed workbooks.

Related

Is there a way to nest the TODAY() function into an external cell reference in Excel?

One of the daily repetitive tasks that my team handles requires using an excel template to format and upload rate indices to our system.
The 9 cells that contain the rates are currently set up as individual outside cell references. The format of the cell formulas are: ='S:\Ext1\Ext2[RATESHEET 02-02-2023.xlsx]RateName'!$C$7
The file being referenced in [RATESHEET 02-02-2023.xlsx] is updated every day with a new file and the current date. Right now, a member of the team has to go in daily and update each reference cell formula with today's date. I want this to update without going in to every cell.
I have three possibilities that seem plausible, but I can't seem to search correctly to figure out if any of these are possible in Excel.
Best case scenario, I would love to nest the function TEXT(TODAY(), "mm-dd-yyyy") into the reference formula and have each reference cell update with the daily date every time the file is opened.
Second best, I considered that all of the cells could reference a dummy cell that has the text/today function already in it.
Third best idea is to provide a user prompt to enter the date in that format, and have it update the cells from there.
Excel wizards, please let me know if there is any good way to accomplish this task.

Indirect Function with Sheet Names

I have a list of all of the sheet names in my workbook on Sheet1 and I am trying, without success, to use the INDIRECT function to reference a cell on another sheet using said name. I am aware that this is a common question, I have looked at about 10 other questions/answers on this website in addition to others. For some reason, those solutions are not working and I am kinda losing my mind.
The sheet names are all in column A
They are named after dates (format mm-dd-yy) <- I'm assuming this is the problem?
The cell that I am trying to reference is always in O1 on every sheet in the workbook.
I have tried:
=INDIRECT(A1&"!O1")
=INDIRECT("'"A1"'&!O1")
and a few other amalgamations. Again, I have looked into so many other solutions at this point I am just left with asking for help with my situation, which is apparently unique (or more likely it is some blaring user error). Please help me before immediately removing the post.
If I have this right, the names of your sheets are dates, and you have the names listed as dates in Column A. So, they will appear as dates, but are actually Excel's background number for a date (days since 1/1/1900).
If you use the Formulas tab in the ribbon to Evaluate Formula, you should see the date pop in to your formula as a 5 digit number.
If you are not doing anything else with these dates, you could try selecting column A and formatting as text. This solved the issue in my test setup. This will still work if you are using the date for other functions, but you will have to tell Excel it's a date using DateValue()
After formatting Column A as text, I used =INDIRECT("'"&A1&"'!O1")
Try,
=indirect(text(a1, "\'mm-dd-yy\'\!\O\1"))

Concatenate seem to wrap in quotes prior to indirect

Goal: Pull data from another excel sheet but name of excel sheet is changed yearly
Thoughts: Excel seems to wrap the below in double quotes. While this may be the problem it is unclear how to resolve it.
=INDIRECT(CONCATENATE(B2,"FY",RIGHT(Financal_Year,2),"_Attendance","\","[FY",RIGHT(Financal_Year,2)," LOG.xlsx]JUN'!B19)"))
In "Show Calculation Steps" I can see that the evaluation looks correct with the EXPECTATION of the double quotes placed where concatenate place its data.
Example Output:
=INDIRECT("'\\networkdrive\FY18_Attendance\[FY18_LOG.xlsx]JUN'!B19")
The output I'm looking for:
=INDIRECT('\\netwrokdrive\FY18_Attendance\[FY18 LOG.xlsx]JUN'!B19)
This way it grabs the data in that block.
If it were me, I would create a shortcut to the current year file and then link my references through that shortcut. Then every year you only have to update what the "current fy" link points to and all other refs fall in line.
I.e. if you want fy18's cell b19 you would insert the following into a cell.
='\\server\path\[current-fy-shortcut.lnk]sheet1'!b19
And then change the current-fy-shortcut to point to fy18-blahblah.xlsx
There may be a way to build the fy reference with indirect but it seems like a whole lot of work for worse payoff. You have to open the referenced workbook for indirect to "see" it(every time). with the method above you just have to change a pointer once a year.
Hope this helps,
SySfS

What is dynamic date?

I want to know what dynamic date is and how to use it. I just know it is something in excel but really not clear. I searched on google some times but still found hard to understand.
In a nutshell, it's a date generated by the Today() function, which updates automatically.
In an excel sheet, type =Today(). This will enter the current date. As this is a volatile function, if you save the file then open it tomorrow, it will have tomorrow's date.

Update Excel VLOOKUP based on newest file

I have an excel file, automatically generated each morning with a generic name (Filename_YYYYMMDD).
Also I have an XLSM file that contains vlookup targeted to the above mentioned generic file.
In a macro, I would like to update the vlookup to point to the NEWEST file automatically created. Newest can mean either with the biggest date in the file name or the freshest creation date in the file properties. It should check either of the two parameters, change the file name in the vlookup formula and then automatically spread the formula to the whole column. The spreading part i can handle, but the date-change part I can not figure out.
Help?
Here is the vlookup:
=IFERROR(IF(H2=1;VLOOKUP(D2;'c:\path\[Filename_20130719.xlsx]Sheet1'!$B:$P;15;FALSE);G2);0)
If you know the date then you can use the replace method.
Something like:
Columns("A").Replace What:="20130719", Replacement:="20130720", LookAt:=xlPart
The catch is you always have to know the current date in the formula and the next date you want to replace.

Resources