PDA

View Full Version : Execute a function stored in text format



Athena_4537
03-16-2023, 11:40 AM
Hello,

In an Excel sheet, I would like to introduce a function (in text format) which will then be retrieved to be applied to various cells, but with the contents of a cell (which will vary dynamically) via the LET function.

For example: Function: x+x^(1/2) or sin(x+1) or 2x^3-3x^2+5*x-3 LET formula obtained by concatenation: LET(x, B40, x+x^(1/2)) or LET(x, B40, sin(x+1)) And then, to execute this function in different places, with B40 which will vary depending on the cell where LET is created: LET(x, C40, x+x^(1/2)) then LET(x, D40, x+x^(1/2))

But how to execute and calculate this function stored in text format?

The function =LET(x, B40, x+x^(1/2)) used directly in a cell gives a result, but if the function (here x+x^(1/2)) changes, all the LETs need to be rewritten...
While a dynamic composition allows you to have the right LET everywhere, but... how to execute it afterwards.

The VBA function gives me errors 2015.

I am open to any solution, even in VBA.

Thank you in advance for your help.

June7
03-16-2023, 01:14 PM
VBA has Eval() function for this purpose.

I don't understand use of LET(). It is not an Excel 2010 cell function. And I have never seen it used in VBA.

arnelgp
03-16-2023, 05:50 PM
you can introduced your Own function in VBA to somewhat mimic Let().

georgiboy
03-17-2023, 02:09 AM
You can also store formulae in the name manager to be used at a later date, see attached, i have added two formulae to the name manager.

p45cal
03-17-2023, 02:31 AM
FYI:
https://www.msofficeforums.com/excel-programming/50591-execute-function-stored-text-format.html
https://www.mrexcel.com/board/threads/execute-a-function-stored-in-text-format.1232643/
https://www.excelforum.com/excel-formulas-and-functions/1401861-execute-a-function-stored-in-text-format.html
also:
https://forum.excel-pratique.com/excel/executer-une-fonction-stockee-au-format-texte-182398
https://www.developpez.net/forums/d2147988/logiciels/microsoft-office/excel/macros-vba-excel/executer-fonction-stockee-format-texte/

georgiboy
03-17-2023, 03:04 AM
FYI:
https://www.msofficeforums.com/excel-programming/50591-execute-function-stored-text-format.html
https://www.mrexcel.com/board/threads/execute-a-function-stored-in-text-format.1232643/
https://www.excelforum.com/excel-formulas-and-functions/1401861-execute-a-function-stored-in-text-format.html
also:
https://forum.excel-pratique.com/excel/executer-une-fonction-stockee-au-format-texte-182398
https://www.developpez.net/forums/d2147988/logiciels/microsoft-office/excel/macros-vba-excel/executer-fonction-stockee-format-texte/

Eeexcellent!

Aussiebear
03-17-2023, 03:49 AM
Oh Dear..... a serial cross poster. Good luck getting assistance here then. A really good thread ruined by the stupidity of over posting the same thread to multiple forums.

Paul_Hossler
03-17-2023, 09:25 AM
Hello,

Thank you in advance for your help.

As others have pointed out .... you can certainly post you question in any of the other Excel forums, but it's considered polite by all of them including us to let members know that the question has been posted other places and to provide the links

That way if you do get an answer else where, we don't spend our time unnecessarily

There's a link in my signature


What is multiposting?Multiposting is the act of posting a single question to different forums around the same time.

We discourage multiposting because it is like calling five cab companies and going with the one that comes first -- it shows disrespect for the volunteers that monitor this forum because they will unknowingly be helping someone who may have already received help elsewhere. Their time is no less important than that of the person asking the question.

Many of the volunteers here visit multiple forums and can easily spot duplicate posts. Some of them may even reply to your posts with a link to your post on another forum. Don't be the person that gets caught.

If you must post your question on a different forum, include a link to the question you have already posted on the previous forum(s). That way, those helping you can decide for themselves if you are already receiving the help you need somewhere else.



If you are still confused, read A message to forum cross posters (http://www.excelguru.ca/node/7).