Preparing worksheets which will compare data from two columns. One of columns will be linked with archived files from prior day. This is my cell formula:
=VLOOKUP("Cash",'C:\...\"&TEXT(TODAY(),"yyyy")&"\"&TEXT(TODAY(),"mmmm")&"\"&TEXT(TODAY()-1,"dd")&"\[XXXX.xls]Check'!$L$10:$M$76,2,0)
Is this formula proper? Still returning N/A. When I put date manualy it works fine. Seems that problem is with TEXT() formula. Any idea?
You're doing it wrong. VLOOKUP() expects range reference as its second parameter. You are posting a reference to excel file named 'C:\...\"&TEXT(TODAY(),"yyyy")&"\"&TEXT(TODAY(),"mmmm")&"\"&TEXT(TODAY()-1,"dd")&"\[XXXX.xls]' because your formulas and & operators will not be evaluated inside apostrophes ''.
You need to wrap the string into INDIRECT() to evaluate it into reference:
=VLOOKUP("Cash",INDIRECT("'C:\...\"&TEXT(TODAY(),"yyyy")&"\"&TEXT(TODAY(),"mmmm")&"\"&TEXT(TODAY()-1,"dd")&"\[XXXX.xls]Check'!$L$10:$M$76"),2,0)
However, don't expect this to open the whatever filename it calculates and fetch the data into your cell — it will return #REF! unless the file it is targeting is not open in Excel right now.
Related
I have a matrix grid in "MasterSheetGrid". I have separate sheets that divide this info into certain dimensions, making it easier to handle for the user.
In order to make the file dynamic, i am trying to use INDIRECT Function within a function, to locate which row of the MasterSheetGrid to look for the information before returning.
The formula works when i specify the row manually, but using INDIRECT i receive a REF error, even though nothing is deleted.
Manual Formula =INDEX(MasterSheetGrid!$5:$5,MATCH((XLOOKUP($J6,$5:$5,6:6)),MasterSheetGrid!6:6,0))
Formula to locate the row
=(MATCH($C6,MasterSheetGrid!$C:$C,0))
Attempt to merge both using INDIRECT by referencing the cell where the above formula is stored, which results in REF
INDEX(MasterSheetGrid!$5:$5,MATCH((XLOOKUP($J6,$5:$5,6:6)),(INDIRECT(J2:J2,0))))
Ideally i would like to not have to use a cell to store the lookup row formula in, but i thought if i could create a correct formula with the cell reference, i could repeat for the formula.
Does anyone know what i am doing wrong?
This is the view of the user. The formula would sit within column K
This is the MasterSheetGrid view
Instead of using INDIRECT which would cause recalculation at any change in the file, I recommend using INDEX instead. You refer to a fixed sheet name, therefore no need to use INDIRECT.
=INDEX(MasterSheetGrid!$5:$5,MATCH((XLOOKUP($J6,$5:$5,6:6)),INDEX(MasterSheetGrid!$1:$50,J2,),0))
Would be the equivalent of what you tried.
Proper use of INDIRECT would be:
=INDEX(MasterSheetGrid!$5:$5,MATCH((XLOOKUP($J6,$5:$5,6:6)),INDIRECT("MasterSheetGrid!"&J2&":"&J2),0))
And it's good practice to take the following into account (thanks David Leal):
If the Sheet name you're referring to contains one or more spaces you need to wrap the name in ' like 'Sheet name'!
To refer a range using INDIRECT you can use the following syntax (as a string delimited, for example delimited by "):
=INDIRECT("J2:J10")
for a cell, this works:
=INDIRECT(J2)
but if you try the same for a range:
=INDIRECT(J2:J10) -> #REF!
you get #REF!
If you are going to refer a Sheet from your Worksheet, then you need in all cases to enter the input argument as string:
=INDIRECT("Sheet1!A1:A10")
=INDIRECT("Sheet1!A1")
=INDIRECT("'Sheet 1'!A2") -> When Sheet Name has spaces use (') delimiter
Notes: By the way you are invoking INDIRECT using the second input argument (a1) which is optional with the value 0. It is not required for getting a referring a range as I showed before.
I suspect this is the issue you are having
In a column, I´m storing ranges as plain Text.
I then want to use these ranges in a formula. As everything so far was in the same workbook I had no issue.
Now I want to get value from another workbook so I added just the path of the file just in front of my range.
It gives me something like that (stored in cell R38):
'C:\Users\me\Documents\C251\[C251output_powereditor.xlsx]C251!'G4:G38
Then I' m trying to use the following formula :
MATCH("Stlnr.";INDIRECT(R38);0)
But I got a ref error.
If I try the following :
MATCH("Stlnr.";[C251output_powereditor.xlsx]C251!G4:G38;0)
It does work.
I´m not sure what the issue is with my indirect function. And before you ask the other workbook is open. :)
Thanks in advance
I think your problem could be that when you enter
'C:\Users\me\Documents\C251[C251output_powereditor.xlsx]C251!'G4:G38
into a cell, Excel treats the first ' as the symbol of starting a text field, so it thinks the path is C:\Users\me\Documents\C251[C251output_powereditor.xlsx]C251!'G4:G38.
Solution: Add a single quote either in the formula or in the data cell:
''C:\Users\me\Documents\C251[C251output_powereditor.xlsx]C251!'G4:G38
or
MATCH("Stlnr.";INDIRECT("'"&R38);0)
I am using an INDIRECT function to get value of a cell (B4) for many sheets in my workbook.
At the moment I have to hard code the name of the sheets like this
=INDIRECT("WCNEXP!$B$4")
Ideally I would like to find a way to compile the name "WCNEXP" with the help of the CONCATENATE formula, like this
=INDIRECT("CONCATENATE(B18,C18)!$B$4")
but it does not work for some reason.
Is there another way to get the name compiled from 2 cells and use the INDIRECT Formula ?
Photo of the workbook
Your code is almost good.
the quotes must be placed after the concatenate function, and with the use of "&" to join them.
=INDIRECT(CONCATENATE(B18,C18)&"!$B$4")
I want to make this formula dynamic by using the values in column C to complete the reference to the right file. That way I can just drag the formula down instead of altering the dates all the time. Some help would be very much appreciated.
Already tried the indirect function but this only seems to work on open workbooks.
=IFERROR(INDEX('G:\AGL''s & TC''s\Performance\2019\ASHIFT\Januari\
["&TEXT(C8,"ddmmyyyy")&".xlsm]PICKING'!$KD$5:$KD$200;MATCH($B$3;'G:\AGL''s &
TC''s\Performance\2019\ASHIFT\Januari\
["&TEXT(C8,"ddmmyyyy")&".xlsm]PICKING'!$A$5:$A$200;0));0)
Mapping is correct. When i use the actual filename the expected results are shown.
Unfortunately, you cannot use a formula to generate a filename for INDEX(), INDIRECT() etc. functions. Excel just doesn't support this.
Excel keeps register of references to external workbooks, and it needs static data for it, so formulas are no-go here.
Alright, I am trying to figure out if the following is possible so that I can use it in later projects. I have been testing and working on this code in a sample workbook, which is why the file name is garbage. So don't judge me.
I have a VLOOKUP:
=VLOOKUP(A6,[dfhdfh.xlsx]Sheet1!$A:$B,2,FALSE)
This function currently works great. But I want to replace the static table_array value in the function to a cell reference, where I can enter a different file name at will.
Something along the lines of:
=VLOOKUP(A3,CONCATENATE("[",F2,"]","Sheet1!$A:$B"),2,FALSE)
Where F2 contains the file name and extension dfhdfh.xlsx
But whenever I try to execute my VLOOKUP with it's nested CONCATENATE function, I get a #VALUE! error. What gives?
Follow up from comments
If your workbook dfhdfh.xlsx is always open, you can use
=VLOOKUP(A3,INDIRECT("["&F2&"]Sheet1!$A:$B"),2,0).
But if your wb is closed, INDIRECT doesn't work. In that case you need VBA solution.
About your formula:
1) CONCATENATE(A1,A2) is the same as A1 & A2.
2) Actually concatenation works and result of CONCATENATE("[",F2,"]","Sheet1!$A:$B") would be "[dfhdfh.xlsx]Sheet1!$A:$B", but excel doesn't recognize this string as reference.
So you need to use Indirect for this purpose:
INDIRECT(CONCATENATE("[",F2,"]","Sheet1!$A:$B")) gives you correct reference.
Entire formula would be:
=VLOOKUP(A3,INDIRECT(CONCATENATE("[",F2,"]","Sheet1!$A:$B")),2,FALSE).
But, using first point, you can make this formula shorter:
=VLOOKUP(A3,INDIRECT("[" & F2 & "]Sheet1!$A:$B"),2,FALSE)