{"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,
\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

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>
\n6.
VBA Control Property<\/a><\/p>\n

\nYou have got all the basic concept about Excel Macro. So now I will show you, how you can start writing Excel Macros.
\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

Step 1.<\/strong>First go to Visual Basic Editor of your workbook (How to open Visual Basic Editor??<\/a>)
\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>\n

Sub My_First_Macro()\nRange(\"A4\").Value = (Range(\"A1\").Value + Range(\"A2\").Value) * Range(\"A3\").Value\nEnd Sub<\/code><\/pre>\n

\n

\"My

My First Simple Macro<\/p><\/div>
\n
\nStep 4.<\/strong> In the A1, A2 and A3, you have entered 25, 30 and 4 respectively.
\n
\n

\"My

My First Simple Macro<\/p><\/div>
\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

Step 6.<\/strong>Now Click on the Run Button to Run the Written Macro.
\n
\n

\"My

My First Simple Macro<\/p><\/div>
\n
\nStep 7.<\/strong>Click on Run
\n
\n

\"My

My First Simple Macro<\/p><\/div>
\n
\nStep 7.<\/strong>After running the Macro, See the Result.
\n
\n

\"My

My First Simple Macro<\/p><\/div>
\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

\"My

My First Simple Macro<\/p><\/div>
\n
\nStep 8.<\/strong>Now Result is changed after running the Macro.
\n
\n

\"My

My First Simple Macro<\/p><\/div>
\n
\nHappy Macro Writing…. \ud83d\ude42 \ud83d\ude42<\/p>\n

<\/p>\n\n\n
\n 
\nTo Check out more Excel Macro Tutorials, visit Excel Macro Tutorial<\/a><\/strong>
\n\n<\/td>\n<\/tr>\n<\/table>\n<\/span>","protected":false},"excerpt":{"rendered":"

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 […]<\/p>\n","protected":false},"author":45,"featured_media":1872,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[1679],"tags":[],"class_list":["post-12101","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-excel-macro-beginner"],"yoast_head":"\nExcel Macro Tutorial : How to write Excel Macro - Your First Excel Macro - Let's excel in Excel<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/vmlogger.com\/excel\/2011\/12\/how-to-create-a-simple-macro\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Excel Macro Tutorial : How to write Excel Macro - Your First Excel Macro\" \/>\n<meta property=\"og:description\" content=\"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 […]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/vmlogger.com\/excel\/2011\/12\/how-to-create-a-simple-macro\/\" \/>\n<meta property=\"og:site_name\" content=\"Let's excel in Excel\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/www.facebook.com\/vmlogger\" \/>\n<meta property=\"article:author\" content=\"http:\/\/www.facebook.com\/vmlogger\" \/>\n<meta property=\"article:published_time\" content=\"2011-12-04T14:00:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/vmlogger.com_-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Vishwamitra Mishra\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/www.twitter.com\/learnexcelmacro\" \/>\n<meta name=\"twitter:site\" content=\"@learnexcelmacro\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Vishwamitra Mishra\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/vmlogger.com\/excel\/2011\/12\/how-to-create-a-simple-macro\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2011\/12\/how-to-create-a-simple-macro\/\"},\"author\":{\"name\":\"Vishwamitra Mishra\",\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5\"},\"headline\":\"Excel Macro Tutorial : How to write Excel Macro – Your First Excel Macro\",\"datePublished\":\"2011-12-04T14:00:13+00:00\",\"dateModified\":\"2011-12-04T14:00:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2011\/12\/how-to-create-a-simple-macro\/\"},\"wordCount\":420,\"commentCount\":13,\"publisher\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5\"},\"image\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2011\/12\/how-to-create-a-simple-macro\/#primaryimage\"},\"thumbnailUrl\":\"\",\"articleSection\":[\"Excel Macro Beginner\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/vmlogger.com\/excel\/2011\/12\/how-to-create-a-simple-macro\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/vmlogger.com\/excel\/2011\/12\/how-to-create-a-simple-macro\/\",\"url\":\"https:\/\/vmlogger.com\/excel\/2011\/12\/how-to-create-a-simple-macro\/\",\"name\":\"Excel Macro Tutorial : How to write Excel Macro - Your First Excel Macro - Let's excel in Excel\",\"isPartOf\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2011\/12\/how-to-create-a-simple-macro\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2011\/12\/how-to-create-a-simple-macro\/#primaryimage\"},\"thumbnailUrl\":\"\",\"datePublished\":\"2011-12-04T14:00:13+00:00\",\"dateModified\":\"2011-12-04T14:00:13+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2011\/12\/how-to-create-a-simple-macro\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/vmlogger.com\/excel\/2011\/12\/how-to-create-a-simple-macro\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/vmlogger.com\/excel\/2011\/12\/how-to-create-a-simple-macro\/#primaryimage\",\"url\":\"\",\"contentUrl\":\"\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/vmlogger.com\/excel\/2011\/12\/how-to-create-a-simple-macro\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/vmlogger.com\/excel\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Excel Macro Beginner\",\"item\":\"https:\/\/vmlogger.com\/excel\/excel-macro-beginner\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Excel Macro Tutorial : How to write Excel Macro – Your First Excel Macro\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/vmlogger.com\/excel\/#website\",\"url\":\"https:\/\/vmlogger.com\/excel\/\",\"name\":\"Let's excel in Excel\",\"description\":\"Let's share knowledge\",\"publisher\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/vmlogger.com\/excel\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5\",\"name\":\"Vishwamitra Mishra\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/avataaars-1.png\",\"contentUrl\":\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/avataaars-1.png\",\"width\":528,\"height\":560,\"caption\":\"Vishwamitra Mishra\"},\"logo\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/image\/\"},\"description\":\"My name is Vishwamitra Mishra. Friends Call me Vishwa. I hold a Bachelor\u2019s Degree in Computer Science from D.A.V.V. Indore & currently working as a Technical Lead having over 7 years of experience.\",\"sameAs\":[\"http:\/\/www.learnexcelmacro.com\",\"http:\/\/www.facebook.com\/vmlogger\",\"https:\/\/x.com\/https:\/\/www.twitter.com\/learnexcelmacro\",\"https:\/\/www.youtube.com\/c\/VMLogger\"],\"url\":\"https:\/\/vmlogger.com\/excel\/author\/vishwamitra\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Excel Macro Tutorial : How to write Excel Macro - Your First Excel Macro - Let's excel in Excel","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/vmlogger.com\/excel\/2011\/12\/how-to-create-a-simple-macro\/","og_locale":"en_US","og_type":"article","og_title":"Excel Macro Tutorial : How to write Excel Macro - Your First Excel Macro","og_description":"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 […]","og_url":"https:\/\/vmlogger.com\/excel\/2011\/12\/how-to-create-a-simple-macro\/","og_site_name":"Let's excel in Excel","article_publisher":"http:\/\/www.facebook.com\/vmlogger","article_author":"http:\/\/www.facebook.com\/vmlogger","article_published_time":"2011-12-04T14:00:13+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/vmlogger.com_-1.png","type":"image\/png"}],"author":"Vishwamitra Mishra","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/www.twitter.com\/learnexcelmacro","twitter_site":"@learnexcelmacro","twitter_misc":{"Written by":"Vishwamitra Mishra","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/vmlogger.com\/excel\/2011\/12\/how-to-create-a-simple-macro\/#article","isPartOf":{"@id":"https:\/\/vmlogger.com\/excel\/2011\/12\/how-to-create-a-simple-macro\/"},"author":{"name":"Vishwamitra Mishra","@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5"},"headline":"Excel Macro Tutorial : How to write Excel Macro – Your First Excel Macro","datePublished":"2011-12-04T14:00:13+00:00","dateModified":"2011-12-04T14:00:13+00:00","mainEntityOfPage":{"@id":"https:\/\/vmlogger.com\/excel\/2011\/12\/how-to-create-a-simple-macro\/"},"wordCount":420,"commentCount":13,"publisher":{"@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5"},"image":{"@id":"https:\/\/vmlogger.com\/excel\/2011\/12\/how-to-create-a-simple-macro\/#primaryimage"},"thumbnailUrl":"","articleSection":["Excel Macro Beginner"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/vmlogger.com\/excel\/2011\/12\/how-to-create-a-simple-macro\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/vmlogger.com\/excel\/2011\/12\/how-to-create-a-simple-macro\/","url":"https:\/\/vmlogger.com\/excel\/2011\/12\/how-to-create-a-simple-macro\/","name":"Excel Macro Tutorial : How to write Excel Macro - Your First Excel Macro - Let's excel in Excel","isPartOf":{"@id":"https:\/\/vmlogger.com\/excel\/#website"},"primaryImageOfPage":{"@id":"https:\/\/vmlogger.com\/excel\/2011\/12\/how-to-create-a-simple-macro\/#primaryimage"},"image":{"@id":"https:\/\/vmlogger.com\/excel\/2011\/12\/how-to-create-a-simple-macro\/#primaryimage"},"thumbnailUrl":"","datePublished":"2011-12-04T14:00:13+00:00","dateModified":"2011-12-04T14:00:13+00:00","breadcrumb":{"@id":"https:\/\/vmlogger.com\/excel\/2011\/12\/how-to-create-a-simple-macro\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/vmlogger.com\/excel\/2011\/12\/how-to-create-a-simple-macro\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/vmlogger.com\/excel\/2011\/12\/how-to-create-a-simple-macro\/#primaryimage","url":"","contentUrl":""},{"@type":"BreadcrumbList","@id":"https:\/\/vmlogger.com\/excel\/2011\/12\/how-to-create-a-simple-macro\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/vmlogger.com\/excel\/"},{"@type":"ListItem","position":2,"name":"Excel Macro Beginner","item":"https:\/\/vmlogger.com\/excel\/excel-macro-beginner\/"},{"@type":"ListItem","position":3,"name":"Excel Macro Tutorial : How to write Excel Macro – Your First Excel Macro"}]},{"@type":"WebSite","@id":"https:\/\/vmlogger.com\/excel\/#website","url":"https:\/\/vmlogger.com\/excel\/","name":"Let's excel in Excel","description":"Let's share knowledge","publisher":{"@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/vmlogger.com\/excel\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5","name":"Vishwamitra Mishra","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/image\/","url":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/avataaars-1.png","contentUrl":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/avataaars-1.png","width":528,"height":560,"caption":"Vishwamitra Mishra"},"logo":{"@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/image\/"},"description":"My name is Vishwamitra Mishra. Friends Call me Vishwa. I hold a Bachelor\u2019s Degree in Computer Science from D.A.V.V. Indore & currently working as a Technical Lead having over 7 years of experience.","sameAs":["http:\/\/www.learnexcelmacro.com","http:\/\/www.facebook.com\/vmlogger","https:\/\/x.com\/https:\/\/www.twitter.com\/learnexcelmacro","https:\/\/www.youtube.com\/c\/VMLogger"],"url":"https:\/\/vmlogger.com\/excel\/author\/vishwamitra\/"}]}},"_links":{"self":[{"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/posts\/12101"}],"collection":[{"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/users\/45"}],"replies":[{"embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/comments?post=12101"}],"version-history":[{"count":0,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/posts\/12101\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/media?parent=12101"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/categories?post=12101"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/tags?post=12101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}