Consulting

Results 1 to 8 of 8

Thread: Execute a function stored in text format

  1. #1

    Execute a function stored in text format

    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.

  2. #2
    VBAX Mentor
    Joined
    Nov 2022
    Location
    The Great Land
    Posts
    331
    Location
    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.
    How to attach file: Reading and Posting Messages (vbaexpress.com), click Go Advanced below post edit window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    you can introduced your Own function in VBA to somewhat mimic Let().
    Attached Files Attached Files

  4. #4
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,186
    Location
    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.
    Attached Files Attached Files
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved

    Excel 365, Version 2403, Build 17425.20146

  5. #5

  6. #6
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,186
    Location
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved

    Excel 365, Version 2403, Build 17425.20146

  7. #7
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,049
    Location
    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.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  8. #8
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    Quote Originally Posted by Athena_4537 View Post
    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.
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •