Excel Macro Tutorial : How to write Excel Macro – Your First Excel Macro
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
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
Step 4. In the A1, A2 and A3, you have entered 25, 30 and 4 respectively.
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.
Step 7.Click on Run
Step 7.After running the Macro, See the Result.
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
Step 8.Now Result is changed after running the Macro.
Happy Macro Writing….
To Check out more Excel Macro Tutorials, visit Excel Macro Tutorial
My name is Vishwamitra Mishra. Friends Call me Vishwa. This blog is authored by me. I am an Excel Geek. Well, this blog talks a lot about my passion in Excels & Macros so I’ll not talk about it :) I am very much passionate about traveling & quite recently discovered that I am a good photographer too..:P
AND GET A FREE!
E-BOOK FOR EXCEL VBA BEGINNERS
DON'T MISS ANY NEW ARTICLE !
Get your FREE! E-Book & Have Every New Article Delivered Straight To Your Email-Box