Consulting

Results 1 to 4 of 4

Thread: HELP to show formula

  1. #1
    VBAX Regular
    Joined
    Feb 2013
    Posts
    7
    Location

    HELP to show formula

    HI out there


    Can somebody tell me how I can to create a function in VBA such that it will shows the calculation of a formula.

    For Example:

    A1=2
    B1=3
    and we set cell C1=A1+B1

    What I want is; to create a function, which take cell C1 and show: 2+3

    Sorry my english.

    Thank you

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Welcome to the forum!

    Most want to show the value or the formula. To do what you want:
    =A1&"+"&B1

  3. #3
    VBAX Regular
    Joined
    Feb 2013
    Posts
    7
    Location
    Quote Originally Posted by Kenneth Hobs
    Welcome to the forum!

    Most want to show the value or the formula. To do what you want:
    =A1&"+"&B1
    Thank you very much.

    And thank you for your quick respons. But I want more to create a function like:

    Function GetFormula(Cell as Range) as String
    GetFormula = Cell.Formula
    End Function

    Where =GetFormula(C1) will show A1+B1

    So is it possible to create a function, like the one above where the outcome will be 2+2 ?
    and how?

    Im quite new in VBA.

  4. #4
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    For simple mathematical operations like +, -, *, /, and such, that can be done. Much more complicated and it gets to be a nightmare.

    When posting code, please paste between VBA code tags. There is no need to quote a post generally. If you must quote, just quote the relavent parts. That is why we have a threaded forum. You can always say, in your post #2 Kenneth, I noticed that you...

    For a formula, you can always use Formulas > Evaluate Formulas, and Evaluate each.

Posting Permissions

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