Excel INDIRECT function - dynamic link not working - excel

I'm using excel 2016 and I've created an INDIRECT formula to combine different cell values into a link but I'm getting #REF!
The cell I'm trying to link to is in another workbook on a network drive and I'm using the UNC folder name. I've compared it to a normal link to the same cell and evaluated my formula and they look identical.
The non-dynamic link (which works!), is this....
='\\admin\user group\aob\[excel file.xlsx]Summary'!A1
The dynamic link (which doens't work) looks like this....
=INDIRECT("'"&$B$8&$B$12&"'!"&Cell_ref!A1)
where $B$8 (the file) is: \admin\user group\aob[excel file.xlsx]
and $B$12 is: Summary
and Cell_ref!A1 is: $A$1
The value returned is #REF! but it should be the value from the cell being referenced.
Any help gratefully received!

Related

How to make a reference in a formula dynamic on cell value base

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.

How to evaluate the content of another cell in the same spreadsheet without any VBA or any other addon

With the cell A1 containing a formula saved as string. Ex: Sum(B1:B5)
In A2 I want to execute content of A1. But when I put =(=A1) in A2 excel gives me formula error. Is there any way I can execute content of A1 in A2 as formula
Mind you no VBA is allowed. Can someone please help?
Please only those people should answer who have done this thing in the past. No hit and tries please
=A1
that's all you need to point the value to the value in cell A1
With VBA :
with VBA you can write some custom function and then evaluate the formula.
Then call the function in excel wherever you required like below
=eval_formula(A1)
Function eval_formula(fr)
eval_formula = Evaluate(fr.Value)
End Function
Refer the link here for more details
https://superuser.com/questions/253353/excel-function-that-evaluates-a-string-as-if-it-were-a-formula
without VBA:
Create a named range and use the named range inside the cell, I have attached the screenshots for your reference
hope this is what you required.
The Evaluate function doesn't exist in Excel anymore.
The only way you can use to evaluate properly is unfortunately only VBA.
In addition to the good answer of Durgaprasad. Here are some other ways to evaluate in the related question:
How to turn a string formula into a "real" formula

How to reference external file by adding TEXT(TODAY()) into path

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.

Indirect function with file path

I am trying to create a formula that will look at four cells and return the contents of a cell defined by the contents of the 4 ref cells. for example:
a1 - file path
a2 - workbook name
a3 - sheet name
a4 - cell ref
I've tried to concantenate the cells to produce the full cell address to use in the indirect fucntion and also tried to 'build' the full address within the indirect function, either way I get a #ref!
I have tried to evaluate the formula and it looks fine as I step through building the file path but on the very last step goes to #ref!
Any advice that anyone can offer is greatly appreciated - Thanks
Indirect() does not work with external files, unless they are open in the same instance of Excel.
A free add-in called "morefunc.xll", which you can download here, contains a function called Indirect.Ext which DOES work with external closed files.
This add-in does not work with 64 bit Excel, though, but if you are using 32bit Excel you will be able to use it.

using hyperlink in a vlookup function

very new to this and only just managed the vlookup, anyway,
i have a workbook which contains two Sheets. On Sheet1 I have the following formula (=VLOOKUP(CZ54,Sheet2!$A$1:$Y$176,3,FALSE)) which displays the ID number from Sheet2. This works correctly but how do I get to appear as a hyperlink so once clicked it goes to the specific cell it got from the vloopkup on Sheet2?
I have tried =HYPERLINK(VLOOKUP(CZ54,Sheet2!$A$1:$Y$176,3,FALSE) but I get the error "Cannot get the specified file".
I would be grateful if anyone can point me in the right direction, thank you.
Ok... this looks crazy. This should work for you. I tested it on my machine and it works:
=HYPERLINK(MID(CELL("filename"),SEARCH("[",CELL("filename")), SEARCH("]",CELL("filename"))-SEARCH("[",CELL("filename"))+1) & ADDRESS(MATCH(CZ54,Sheet2!$A$1:$A$176),3,,,"sheet2"),VLOOKUP(CZ54,Sheet2!$A$1:$Y$176,3,FALSE))
Let's break it up a little just to explain some of the parts:
MID(CELL("filename"),SEARCH("[",CELL("filename")), SEARCH("]",CELL("filename"))-SEARCH("[",CELL("filename"))+1)
Returns a string [currentFileName], which is the required format for a hyperlink within a workbook.
MATCH(CZ54,Sheet2!$A$1:$A$176),3,,,"sheet2")
Returns the row number of value of CZ54 in the first column of your VLookup range.
ADDRESS(MATCH(CZ54,Sheet2!$A$1:$A$176),3,,,"sheet2")
Returns the address of the row found, and the column(3, from your vlookup) in sheet2.
So combined:
MID(CELL("filename"),SEARCH("[",CELL("filename")), SEARCH("]",CELL("filename"))-SEARCH("[",CELL("filename"))+1) & ADDRESS(MATCH(CZ54,Sheet2!$A$1:$A$176),3,,,"sheet2")
Returns the actual address for the hyperlink, which is the first parameter of the HYPERLINK formula.
The second parameter is the Vlookup you provided, and voilà.
Edit: A warning if anyone tries to use this for a similar issue, if the lookup_array used in Match or Vlookup does not start with Row 1 or column 1 respectively, you will need to offset the values sent to ADDRESS with a +(starting row or column - 1). Example: Match(CZ54,$A$2:$A$176)+1 instead of MATCH(CZ54,Sheet2!$A$1:$A$176).
Here's a more compact version of Daniel's formula.
Using Hyperlink to link to another sheet in the same workbook, you can replace the reference to the workbook name with #.
Eg =HYPERLINK("#Sheet2!$C$10","Click Here")
So, applying this you get
=HYPERLINK("#"&ADDRESS(MATCH(E21,Sheet2!$A$1:$A$176),3,,,"sheet2"),VLOOKUP(E21,Sheet2!$A$1:$Y$176,3,FALSE))
HYPERLINK is looking for text so if you were to do something like
=HYPERLINK(left(VLOOKUP(CZ54,Sheet2!$A$1:$Y$176,3,FALSE),255))
it should return a usable hyperlink

Resources