Results 1 to 4 of 4

How to Insert Formula by using the Macro in Microsoft Excel

Threaded View

  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:-

    Sub Add_formula()
    Dim A As Range
    Dim B As Range
    Dim C As Range
    Set A = Range("A2")
    Set B = Range("B2")
    Set C = Range("C2")
    C.Value = B.Value - A.Value
    End Sub
    • 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.

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