{"id":12101,"date":"2011-12-04T14:00:13","date_gmt":"2011-12-04T14:00:13","guid":{"rendered":"http:\/\/www.learnexcelmacro.com\/?p=882"},"modified":"2011-12-04T14:00:13","modified_gmt":"2011-12-04T14:00:13","slug":"how-to-create-a-simple-macro","status":"publish","type":"post","link":"https:\/\/vmlogger.com\/excel\/2011\/12\/how-to-create-a-simple-macro\/","title":{"rendered":"Excel Macro Tutorial : How to write Excel Macro – Your First Excel Macro"},"content":{"rendered":"
Dear Readers, 4. Visual Basic Editor in Excel<\/a><\/p>\n 5. How to add different types of controls like Text Box, Radio button, button etc. in Excel<\/a> \nYou have got all the basic concept about Excel Macro. So now I will show you, how you can start writing Excel Macros. Step 1.<\/strong>First go to Visual Basic Editor of your workbook (How to open Visual Basic Editor??<\/a>) \n My First Simple Macro<\/p><\/div> My First Simple Macro<\/p><\/div> Step 6.<\/strong>Now Click on the Run Button to Run the Written Macro. My First Simple Macro<\/p><\/div> My First Simple Macro<\/p><\/div> My First Simple Macro<\/p><\/div> My First Simple Macro<\/p><\/div> My First Simple Macro<\/p><\/div> <\/p>\n
\n
\nTill now we have learnt following things in Excel Macro Tutorial <\/a><\/strong>. In this part of Tutorial you are going to learn how to open the VBE Code Window<\/strong> in Visual Basic Editor<\/a> of your Workbook and start writing your first macro.
\n
\n1. What is Excel Macro ?<\/a>
\n2. How to Record Macro \/ How to Run Macro<\/a>
\n3. Add Developer Tab in Excel \u2013 2007 and 2010<\/a><\/p>\n
\n6. VBA Control Property<\/a><\/p>\n
\nExample: 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. <\/strong>
\n
\nFollow the below Steps, to write your first Excel Macro an Achieve the above mentioned requirement<\/strong>
\n<\/p>\n
\nStep 2.<\/strong>Double Click on the Sheet Name under VBA Project<\/strong> in right side of the Visual Basic Editor.
\nStep 3.<\/strong> Copy and Paste the below Code in the Code Window
\n<\/p>\nSub My_First_Macro()\nRange(\"A4\").Value = (Range(\"A1\").Value + Range(\"A2\").Value) * Range(\"A3\").Value\nEnd Sub<\/code><\/pre>\n
\n
\nStep 4.<\/strong> In the A1, A2 and A3, you have entered 25, 30 and 4 respectively.
\n
\n
\n
\nStep 5.<\/strong>Now after running the above macro, Sum of A1 and A2 should be multiplied with A3 and result must be stored in A4.<\/p>\n
\n
\n
\n
\nStep 7.<\/strong>Click on Run
\n
\n
\n
\nStep 7.<\/strong>After running the Macro, See the Result.
\n
\n
\n
\nCongratulations you have run and tested you first macro.
\n
\nStep 7.<\/strong>Now go to your Sheet and Enter some Other Values as Input and Press Alt+F8<\/strong>
\n
\n
\n
\nStep 8.<\/strong>Now Result is changed after running the Macro.
\n
\n
\n
\nHappy Macro Writing…. \ud83d\ude42 \ud83d\ude42<\/p>\n