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.
Related
I want to enter a formula in a cell as a string, and then reference that string into a formula.
Example:
Cell A1 contains the text 'SUM(K2:K10)*5' (no calculation)
Cell B1=10+(A1)
Result B1=10+SUM(K2:K10)*5) and actually calculates.
Also needs to work if A1 is not a full formula, but I just want that string of text used in B1 as part of the formula as if it was naturally in B1.
So if A1 was just the string 'SU' and in B1 I put =A1&M(K2:K10) it would combine SU and M and calculate as a proper formula as =SUM(K2:K10)
Now I can change the text in A1 to mimic more complex formulas and B1 will act as if that text is truly a part of the formula and calculate. From what I read the function =EVALUATE does this, but it appears to not be in newer excel? I just keep getting error that function is not valid and not in function library..
Maybe a way to use Indirect or Concate to achieve this?
Thanks.
365 Excel 2020 64bit
You can do it with help of Name Manager (VBA is an option but in the context of this question, I am ruling this out)
Formulas tab – Name Manager – New – Put any name in Name: box, say you put GetResult
Put following in Refer To: box
=EVALUATE($A$1)
Now in B1, just put following
=GetResult
Note - If you use this approach, then you will have to save your file as .xlsm.
EVALUATE is and old Excel version 4 macro language function and is not directly available as a worksheet function. You can build a VBA UDF to get at the VBA EVALUATE method (which BTW has a lot of "strange behaviours". Or if you have LAMBDA you can build a named Lambda that calls Evaluate.
Named Lambda called Evil with a formula =LAMBDA(x,EVALUATE(x))
then if your formula string is in cell Z99 you can call the Evil Lambda as =Evil(Z99)
But be aware that using XLM macro functions in this way is deprecated and can fall foul of anti-virus etc.
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!
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
I have searched the site but could not find a satisfactory answer.
I have the path of the directory in Cell A1 = C:\Sundeep\
I have the file name in Cell B1 = ibm
I want the value of cell C6 on sheet data in the file
C:\Sundeep[ibm.xlsm]data!C6
and want to put it in cell C1 in the current workbook. I don't want to use vba code and I don't want to use indirect (as that requires the ibm.xlsm to be open).
If I put this string in C1 (hardcoded), then it works
='C:\sundeep[ibm.xlsm]data'!$C$6
However, if I try something like this
=CONCATENATE("'",A1,"[",B1,".xlsm]data'!")$c$6
it does not work.
Any help is appreciated.
You cannot use the cell value to be redirected to a workbook since even using Indirect() with the closed workbook will also fail.
You have to use Indirect.Ext() function of Morefunc add-in.
I'm familiar with using the following to pull data in from another spreadsheet....
=[filename.xlsm]Sheet!A1
My question is, can I specify the filename in a cell (like AI) then use that cell reference in order to pull that data in...
A1 = filename.xlsm
Then the corresponding cell formula would be
=[AI]Sheet!A1
Such that if I changed the name of the file in cell A1 I would change the reference and pull data from another source? The above is just an example, it doesn't work so my question is can this be done and if so, how?
** The file that I am pulling data from may not be open at the same time **
Many thanks.
Yep! Using Indirect() you can:
If A1 has a filename, in B1 you can put:
=Indirect("'["&A1&"]Sheet1'!A1")
Note: With Indirect(), your workbook that you're referring to has to be open, otherwise you'll see an #REF error.