+ Reply to Thread
Results 1 to 10 of 10

Display Formula in A1, Result in A2

  1. #1
    Registered User
    Join Date
    09-26-2007
    Posts
    5

    Display Formula in A1, Result in A2

    I have a formula in A1 that I would like to execute from A2. I want the A1 to display the formula (so no "="), but I would like cell A2 to execute the formula in A1.

    If A1 contains: "SUM(1+2)", how can I get A2 to display "3" without reproducing the formula?

    A1: SUM(1+2)
    A2: ????

    I suppose I'm looking for something like this:
    A2: ==A1
    But, of course, that doesn't work.

    If I do this it gets close:
    A2: ="="&A1
    But that returns "=SUM(1+2)" instead of executing the formula.

    What do you think?

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Try this:

    Go to Insert|Name|Define and enter the word "FormEval" without quotes, in the Names in workbook field

    In the refers to field enter: =EVALUATE(INDEX(A:A,ROW()-1))

    Click Ok.

    Now in A2, just enter FormEval

    This will evaluate the formula in the cell directly above where you enter it.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Display Formula in A1, Result in A2

    Excel doesn't have an EVALUATE type of function.

    You'd need to create a User Defined Function in VBA to effect what you want.

    Here's an example, in its simplest form:

    Please Login or Register  to view this content.
    Usage:
    If A1:A5 contains the series 1,2,3,4,5

    B1: SUM(A1:A5)

    This formula would return the results of the B1 expression:
    C1: =EvalCell(B1)

    In the example, it returns: 15
    the sum of 1+2+3+4+5

    Does that help?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  4. #4
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Display Formula in A1, Result in A2

    I completely forgot about that little named_formula trick, NBVC!
    If it's what the OP needs...then "Kudos" to you for thinking of it.

    (They say the first thing to go is your eyes...and the second is...ummmm..I can't remember.)

  5. #5
    Registered User
    Join Date
    09-26-2007
    Posts
    5

    Thanks!

    Thanks for your quick reply. Unfortunately the VBA solution won't work for me — I'm running Excel 2004 on a Mac.

    Is there anyway to do this without VBA?

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Not sure if my solution works on a Mac...but you could give it a try...it is not VBA

  7. #7
    Registered User
    Join Date
    09-26-2007
    Posts
    5

    Nope, that didn't work

    Unfortunately that didn't work for me either.

    Anyone else?

    I'm looking for this result...

    ---------------
    | SUM(1+2) |
    ---------------
    | 3 |
    ---------------

    How can I display the result of the equation in A1 in A2?

  8. #8
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    See attached for an example... does it work for you? You should see a 3 in A2 and in C2

    Go to Insert|Name|Define and select FormEval to see formula....
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    09-26-2007
    Posts
    5

    Thanks!

    It worked... And I understand now. Thanks for your patience and for the sample file.

    One more challenge for you...

    Is it possible for FormEval to include a variable from the cell it's called from?

    Please Login or Register  to view this content.
    Where FormEval is =EVALUATE(EVALUATE(A1 & VAR))
    And the result in A2 is "Display this text in A2"

    Another way to ask this is:
    Is it possible to build a formula using 2 cells and evaluate that formula in a third cell?

    See attachment for xls version of the above.

  10. #10
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    You didn't leave an attachment.... so I guessed....see my attached.

    In Sheet2, I have "Sheet1!" in A1 and "B2" in B1 and in Sheet1, I have "diplay this text in A2"

    In Sheet2, A2, I enter formula =FormEval which is defined as =EVALUATE(Sheet2!A1&Sheet2!B1)

    Hope this is what you needed. Let me know if it's not.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1