+ Reply to Thread
Results 1 to 7 of 7

Extracting formula instead of result from cell

  1. #1
    Registered User
    Join Date
    12-07-2005
    Posts
    10

    Question Extracting formula instead of result from cell

    Hi,

    Is it possible to get the forumla from a cell instead of a the result of the forumla using VBA/Macros?

    e.g. In cell A1 I have the formula B1+C1.

    I want to retrieve this formula and furthermore it wud be great if I could get the values in B1 and C1, but I think once the formula can be extracted, the rest will be easy.

    Thanks!!

  2. #2
    Rowan Drummond
    Guest

    Re: Extracting formula instead of result from cell

    Try:

    Debug.Print Range("A1").Formula

    Hope this helps
    Rowan

    lithium81 wrote:
    > Hi,
    >
    > Is it possible to get the forumla from a cell instead of a the result
    > of the forumla using VBA/Macros?
    >
    > e.g. In cell A1 I have the formula B1+C1.
    >
    > I want to retrieve this formula and furthermore it wud be great if I
    > could get the values in B1 and C1, but I think once the formula can be
    > extracted, the rest will be easy.
    >
    > Thanks!!
    >
    >


  3. #3
    Registered User
    Join Date
    12-07-2005
    Posts
    10
    Hi,

    Thanks! When I do the debug.print, I don't see any output, perhaps I am using it the wrong way. Could someone help please?

    Will this put the data into a variable?

    Thanks!

  4. #4
    Rowan Drummond
    Guest

    Re: Extracting formula instead of result from cell

    If you want it in a variable then:

    dim strFml as string
    strFml = range("A1").formula

    Regards
    Rowan

    lithium81 wrote:
    > Hi,
    >
    > Thanks! When I do the debug.print, I don't see any output, perhaps I am
    > using it the wrong way. Could someone help please?
    >
    > Will this put the data into a variable?
    >
    > Thanks!
    >
    >


  5. #5
    Registered User
    Join Date
    12-07-2005
    Posts
    10
    Thank you! That works great!

  6. #6
    Rowan Drummond
    Guest

    Re: Extracting formula instead of result from cell

    You're welcome.

    lithium81 wrote:
    > Thank you! That works great!
    >
    >


  7. #7
    David McRitchie
    Guest

    Re: Extracting formula instead of result from cell

    Hi lithium81,
    Debug statement results from VBA code appear on the Intermediate
    window in the Visual Basic Editor (Ctrl+G).

    For what you want I would suggest the use and flexibility of a
    User Defined Function see GetFormula at
    http://www.mvps.org/dmcritchie/excel...htm#getformula
    if it is not obvious where the formula referenced actually is at,
    then a variation GetFormulaD might work better for you.
    ---
    HTH,
    David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
    My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
    Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

    "Rowan Drummond" <[email protected]> wrote in message news:[email protected]...
    > If you want it in a variable then:
    >
    > dim strFml as string
    > strFml = range("A1").formula
    >
    > Regards
    > Rowan
    >
    > lithium81 wrote:
    > > Hi,
    > >
    > > Thanks! When I do the debug.print, I don't see any output, perhaps I am
    > > using it the wrong way. Could someone help please?
    > >
    > > Will this put the data into a variable?
    > >
    > > 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