+ 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
    313

    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: Office 365 in Windows environment
    Posts
    8,613

    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 2007,2010,365
    Posts
    44,336

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

    Interesting that the Code Tags were added by EFManagement.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    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: Office 365 in Windows environment
    Posts
    8,613

    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)

Similar Threads

  1. Microsoft Excel 2010 Doesn't Support Microsoft Excel 2007
    By Orange.CL in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 07-01-2010, 03:21 AM
  2. Microsoft Office Excel, Unable to get the Insert property of the .... Exel 2003
    By smithcza in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-07-2008, 12:46 PM
  3. How to insert a Check Box to a Microsoft Office Excel Spreadsheet.
    By DannyInTroubleWithExcel in forum Excel General
    Replies: 1
    Last Post: 07-12-2006, 03:25 AM
  4. Replies: 3
    Last Post: 12-07-2005, 12:00 PM
  5. Replies: 1
    Last Post: 05-12-2005, 08:06 PM

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