+ Reply to Thread
Results 1 to 3 of 3

Cell contents is a macro

  1. #1
    Tagas
    Guest

    Cell contents is a macro

    Hi everyone,

    Is it possible for the contents of a cell to be the result of a macro, so
    that observable behaviour similar to a formula is achieved (ie: it
    automatically recalculates the cell contents if any of the values the
    formula uses changes?) - I ask this because I need the cell to display the
    results of a calculation which is difficult and error prone to do in one
    line, whereas the use of VBA would be good.

    Thanks



  2. #2
    NickHK
    Guest

    Re: Cell contents is a macro

    Tagas,
    You can create Public user defined functions in .bas in the VBA.
    Also, look into Volatile for recalculation modes.
    NickHK

    "Tagas" <[email protected]> wrote in message
    news:[email protected]...
    > Hi everyone,
    >
    > Is it possible for the contents of a cell to be the result of a macro, so
    > that observable behaviour similar to a formula is achieved (ie: it
    > automatically recalculates the cell contents if any of the values the
    > formula uses changes?) - I ask this because I need the cell to display

    the
    > results of a calculation which is difficult and error prone to do in one
    > line, whereas the use of VBA would be good.
    >
    > Thanks
    >
    >




  3. #3
    Patrick Molloy
    Guest

    RE: Cell contents is a macro

    read help on User Defined Functions

    eg
    PUBLIC FUNCTION MyFunc(var1,var2,var3) as double

    ' my formula here
    'Dim Result as Double
    Result = (var1 + var2) / var3
    MyFunc = Result
    END FUNCTION


    This should be placed on a standard code module

    Patrick Molloy
    Microsoft Excel MVP



    "Tagas" wrote:

    > Hi everyone,
    >
    > Is it possible for the contents of a cell to be the result of a macro, so
    > that observable behaviour similar to a formula is achieved (ie: it
    > automatically recalculates the cell contents if any of the values the
    > formula uses changes?) - I ask this because I need the cell to display the
    > results of a calculation which is difficult and error prone to do in one
    > line, whereas the use of VBA would be good.
    >
    > Thanks
    >
    >


+ 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