Dear Readers,
 
Till now we have learnt following things in Excel Macro Tutorial . In this part of Tutorial you are going to learn how to open the VBE Code Window in Visual Basic Editor of your Workbook and start writing your first macro.
 
1. What is Excel Macro ?
2. How to Record Macro / How to Run Macro
3. Add Developer Tab in Excel – 2007 and 2010

4. Visual Basic Editor in Excel

5. How to add different types of controls like Text Box, Radio button, button etc. in Excel
6. VBA Control Property

You have got all the basic concept about Excel Macro. So now I will show you, how you can start writing Excel Macros.
Example: You are going to write your first Excel Macro. By running that Excel Macro you will add the Value of Cell A1 and A2 and multiply that Sum with the Value of Cell A3. Store this Result in Cell A4. This is your requirement to write Macros.

Follow the below Steps, to write your first Excel Macro an Achieve the above mentioned requirement

Step 1.First go to Visual Basic Editor of your workbook (How to open Visual Basic Editor??)
Step 2.Double Click on the Sheet Name under VBA Project in right side of the Visual Basic Editor.
Step 3. Copy and Paste the below Code in the Code Window

Sub My_First_Macro()
Range("A4").Value = (Range("A1").Value + Range("A2").Value) * Range("A3").Value
End Sub

My First Simple Macro

My First Simple Macro



Step 4. In the A1, A2 and A3, you have entered 25, 30 and 4 respectively.

My First Simple Macro

My First Simple Macro



Step 5.Now after running the above macro, Sum of A1 and A2 should be multiplied with A3 and result must be stored in A4.

Step 6.Now Click on the Run Button to Run the Written Macro.

My First Simple Macro

My First Simple Macro



Step 7.Click on Run

My First Simple Macro

My First Simple Macro



Step 7.After running the Macro, See the Result.

My First Simple Macro

My First Simple Macro



Congratulations you have run and tested you first macro.
 
Step 7.Now go to your Sheet and Enter some Other Values as Input and Press Alt+F8

My First Simple Macro

My First Simple Macro



Step 8.Now Result is changed after running the Macro.

My First Simple Macro

My First Simple Macro



Happy Macro Writing…. 🙂 🙂

 
To Check out more Excel Macro Tutorials, visit Excel Macro Tutorial