+ Reply to Thread
Results 1 to 4 of 4

How to Insert Formula by using the Macro in Microsoft Excel

  1. #1
    Valued Forum Contributor
    Join Date
    05-07-2014
    Location
    India
    MS-Off Ver
    MS Office 365
    Posts
    312

    How to Insert Formula by using the Macro in Microsoft Excel

    In this article we will learn how to insert the formula in VBA and what is the use of it to write the VBA code.
    When you having problem with inserting formula into cells in VBA. How we should explain the syntax in VBA coding.
    For Example: - I want to insert the formula in Cell C2, =B2-A2. Follow below given steps to write the code in VBE.
    • Open Excel file and then Press the key Alt+F11 on the keyboard.
    • VBE page will get open.
    • Write the below mentioned code:-

    Please Login or Register  to view this content.
    • To run the Macro press the key F5 on your keyboard.
    • Formula will calculate by subtracting the numbers.

    By using this way we can easily define the syntax and use of it while writing the VBA code.
    Last edited by EFmanagement; 04-03-2015 at 12:08 AM.

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: 2019 but still use also older versions
    Posts
    6,660

    Re: How to Insert Formula by using the Macro in Microsoft Excel

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon (Icon! Not write hash character) at the top of your post window. More information about these and other tags can be found here

    Moderator comment: This thread should not receive responses until OP complies with request for code tags
    Last edited by alansidman; 04-02-2015 at 01:19 PM.
    Best Regards,

    Kaper

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2003,2007,2010
    Posts
    29,342

    Re: How to Insert Formula by using the Macro in Microsoft Excel

    Interesting that the Code Tags were added by EFManagement.
    Trevor Shuttleworth - Excel Aid

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: 2019 but still use also older versions
    Posts
    6,660

    Re: How to Insert Formula by using the Macro in Microsoft Excel

    Just a comment: Don't get fooled by a title. The code will NOT insert the formula in a cell. It will insert the result of formula.

+ 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