+ Reply to Thread
Results 1 to 4 of 4

Converting Existing formulas into Macros in Excel 2011

Hybrid View

  1. #1
    Registered User
    Join Date
    10-13-2012
    Location
    Nutley,NJ
    MS-Off Ver
    Excel 2011
    Posts
    77

    Converting Existing formulas into Macros in Excel 2011

    I have a spreadsheet full of formulas and I just want to turn those formulas into macros

    Ex.
    A1 - to be filled by user
    A2 - to be filled by user
    A3 = A1 + A2

    How do I turn the contents of A3 into a macro?

    ...end of my rope...I'm using Excel 2011, sorry for the oversimplistic question
    Last edited by Jhertilus; 10-13-2012 at 10:48 PM.

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Converting Existing formulas into Macros in Excel 2011

    You can do this...

    Sub fill_formulas()
        Range("A3").Formula = "=A1+A2"
    End Sub
    or

    Enter =A1+A2 into cell A3. Turn on the macro recorder and with you cursor on A3, select F2 then Enter

    Turn off the macro recorder and look in the VBE. The macro has been recorded but it will be in the R1C1 style

    After you record the macro, you can convert

    FormulaR1C1 = "=R[-2]C+R[-1]C"
    into the non R1C1 style if you would prefer.

    In the VBE, Ctrl + G will open up the Immediate Window and then enter

    debug.print Application.ConvertFormula("=R[-2]C+R[-1]C", xlR1C1, xlA1)
    and at the end of the line press enter

    You should now see

    debug.print Application.ConvertFormula("=R[-2]C+R[-1]C", xlR1C1, xlA1)
    =A2+A3
    Last edited by jeffreybrown; 10-13-2012 at 11:14 PM.
    HTH
    Regards, Jeff

  3. #3
    Registered User
    Join Date
    10-13-2012
    Location
    Nutley,NJ
    MS-Off Ver
    Excel 2011
    Posts
    77

    Re: Converting Existing formulas into Macros in Excel 2011

    Thank you Jeff very much appreciated!

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Converting Existing formulas into Macros in Excel 2011

    You are very welcome. Hope it has answered your concerns? If it has...

    -------------------------------------------------------------------------------

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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