{"id":5285,"date":"2013-05-01T11:18:48","date_gmt":"2013-05-01T17:18:48","guid":{"rendered":"http:\/\/sanuja.com\/blog\/?p=5285"},"modified":"2020-05-31T13:48:18","modified_gmt":"2020-05-31T19:48:18","slug":"visual-basic-script-using-the-interface","status":"publish","type":"post","link":"https:\/\/sanuja.com\/blog\/visual-basic-script-using-the-interface","title":{"rendered":"Visual Basic Script using the Interface"},"content":{"rendered":"<p>This is the second article a ongoing series of VB scripting guide. If you are unfamiliar with programming in Microsoft Excel, don&#8217;t be afraid, start your journey into VisualBasic with <a href=\"http:\/\/sanuja.com\/blog\/excel-visual-basic-scripts\/\">basics of VB explained here<\/a>.<\/p>\n<p>Macro recorder is great for those who are new to the coding in general. A user can utilize the graphical front end of Excel to generate Modules, which can be modified using conventional VBA Editor.<\/p>\n<p> <!--more--><\/p>\n<p>Find the <em>Developer<\/em> section, then choose &#8220;Record Macro&#8221;.<\/p>\n<p><img decoding=\"async\" data-attachment-id=\"5240\" data-permalink=\"https:\/\/sanuja.com\/blog\/dev_options_mrc_rec\" data-orig-file=\"https:\/\/sanuja.com\/blog\/wp-content\/uploads\/2013\/05\/dev_options_mrc_rec.jpg\" data-orig-size=\"586,115\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"dev_options_mrc_rec\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/sanuja.com\/blog\/wp-content\/uploads\/2013\/05\/dev_options_mrc_rec-300x58.jpg\" data-large-file=\"https:\/\/sanuja.com\/blog\/wp-content\/uploads\/2013\/05\/dev_options_mrc_rec.jpg\" src=\"http:\/\/sanuja.com\/blog\/wp-content\/uploads\/2013\/05\/dev_options_mrc_rec.jpg\" alt=\"dev_options_mrc_rec\" width=\"586\" height=\"115\" class=\"aligncenter size-full wp-image-5240\" srcset=\"https:\/\/sanuja.com\/blog\/wp-content\/uploads\/2013\/05\/dev_options_mrc_rec.jpg 586w, https:\/\/sanuja.com\/blog\/wp-content\/uploads\/2013\/05\/dev_options_mrc_rec-300x58.jpg 300w\" sizes=\"(max-width: 586px) 100vw, 586px\" \/><br \/>\nClick &#8220;OK&#8221; when the Record Macro Options window pop up.<br \/>\n<img decoding=\"async\" data-attachment-id=\"5245\" data-permalink=\"https:\/\/sanuja.com\/blog\/excel_vb_record_pop\" data-orig-file=\"https:\/\/sanuja.com\/blog\/wp-content\/uploads\/2013\/05\/excel_vb_record_pop.jpg\" data-orig-size=\"355,292\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"excel_vb_record_pop\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/sanuja.com\/blog\/wp-content\/uploads\/2013\/05\/excel_vb_record_pop-300x246.jpg\" data-large-file=\"https:\/\/sanuja.com\/blog\/wp-content\/uploads\/2013\/05\/excel_vb_record_pop.jpg\" src=\"http:\/\/sanuja.com\/blog\/wp-content\/uploads\/2013\/05\/excel_vb_record_pop.jpg\" alt=\"excel_vb_record_pop\" width=\"355\" height=\"292\" class=\"aligncenter size-full wp-image-5245\" srcset=\"https:\/\/sanuja.com\/blog\/wp-content\/uploads\/2013\/05\/excel_vb_record_pop.jpg 355w, https:\/\/sanuja.com\/blog\/wp-content\/uploads\/2013\/05\/excel_vb_record_pop-300x246.jpg 300w\" sizes=\"(max-width: 355px) 100vw, 355px\" \/><br \/>\nOnce you are done, click &#8220;Stop Recording&#8221; on the <em>Developer<\/em> section.<br \/>\n<img decoding=\"async\" data-attachment-id=\"5248\" data-permalink=\"https:\/\/sanuja.com\/blog\/excel_vb_record_stop\" data-orig-file=\"https:\/\/sanuja.com\/blog\/wp-content\/uploads\/2013\/05\/excel_vb_record_stop.jpg\" data-orig-size=\"235,111\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"excel_vb_record_stop\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/sanuja.com\/blog\/wp-content\/uploads\/2013\/05\/excel_vb_record_stop.jpg\" data-large-file=\"https:\/\/sanuja.com\/blog\/wp-content\/uploads\/2013\/05\/excel_vb_record_stop.jpg\" src=\"http:\/\/sanuja.com\/blog\/wp-content\/uploads\/2013\/05\/excel_vb_record_stop.jpg\" alt=\"excel_vb_record_stop\" width=\"235\" height=\"111\" class=\"aligncenter size-full wp-image-5248\" \/><br \/>\nNow you can open the Macro your created by Alt + F11. It will open the VB Editor (MS Visual Basic for Applications. On the left hand side of the VB Editor, under VBAProject section, you should see a <em>Modules<\/em> folder. Under that folder you will be able to open your script for editing.<br \/>\n<img decoding=\"async\" data-attachment-id=\"5250\" data-permalink=\"https:\/\/sanuja.com\/blog\/excel_vb_rec_edit\" data-orig-file=\"https:\/\/sanuja.com\/blog\/wp-content\/uploads\/2013\/05\/excel_vb_rec_edit.jpg\" data-orig-size=\"576,431\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"excel_vb_rec_edit\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/sanuja.com\/blog\/wp-content\/uploads\/2013\/05\/excel_vb_rec_edit-300x224.jpg\" data-large-file=\"https:\/\/sanuja.com\/blog\/wp-content\/uploads\/2013\/05\/excel_vb_rec_edit.jpg\" src=\"http:\/\/sanuja.com\/blog\/wp-content\/uploads\/2013\/05\/excel_vb_rec_edit.jpg\" alt=\"excel_vb_rec_edit\" width=\"576\" height=\"431\" class=\"aligncenter size-full wp-image-5250\" srcset=\"https:\/\/sanuja.com\/blog\/wp-content\/uploads\/2013\/05\/excel_vb_rec_edit.jpg 576w, https:\/\/sanuja.com\/blog\/wp-content\/uploads\/2013\/05\/excel_vb_rec_edit-300x224.jpg 300w\" sizes=\"(max-width: 576px) 100vw, 576px\" \/><\/p>\n<p>Above image (last one) is an example of what you would get once Excel has taken your input and converted into a VBScript. What I recorded for this example is the addition of two cells, C1 and C2 and printing it in A4. Please note the A3 cell select. It is not used in any operations of this script. It was inserted because I click on the A3 cell while the Macro Record is in operation. Wile the record is in operation, everything you select and do on the Excel will be added to the VBScript. This is why writing a script in it&#8217;s native form is more beneficial than to use the graphical front end interface. To write scripts in the native form, you must first learn the basis of VB programming. We will discuss this on a later article. Until then, happy coding!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is the second article a ongoing series of VB scripting guide. If you are unfamiliar with programming in Microsoft Excel, don&#8217;t be afraid, start your journey into VisualBasic with basics of VB explained here. Macro recorder is great for those who are new to the coding in general. A user can utilize the graphical &hellip; <a href=\"https:\/\/sanuja.com\/blog\/visual-basic-script-using-the-interface\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Visual Basic Script using the Interface<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":5250,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3],"tags":[31],"class_list":["post-5285","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-computer-science","tag-visualbasic"],"jetpack_featured_media_url":"https:\/\/sanuja.com\/blog\/wp-content\/uploads\/2013\/05\/excel_vb_rec_edit.jpg","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/sanuja.com\/blog\/wp-json\/wp\/v2\/posts\/5285","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sanuja.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sanuja.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sanuja.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/sanuja.com\/blog\/wp-json\/wp\/v2\/comments?post=5285"}],"version-history":[{"count":0,"href":"https:\/\/sanuja.com\/blog\/wp-json\/wp\/v2\/posts\/5285\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sanuja.com\/blog\/wp-json\/wp\/v2\/media\/5250"}],"wp:attachment":[{"href":"https:\/\/sanuja.com\/blog\/wp-json\/wp\/v2\/media?parent=5285"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sanuja.com\/blog\/wp-json\/wp\/v2\/categories?post=5285"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sanuja.com\/blog\/wp-json\/wp\/v2\/tags?post=5285"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}