«

»

May 01 2013

Print this Post

Visual Basic Script using the Interface

This is the second article a on going series of VB scripting guide. If you are unfamiliar with programming in Microsoft Excel, don’t be afraid, start your journey into VisualBasic with basics of VB explained here.

Macro recorder is a 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.

Find the Developer section.

Choose “Record Macro”
dev_options_mrc_rec
Click “OK” when the Record Macro Options window pop up.
excel_vb_record_pop
Once you are done, click “Stop Recording” on the Developer section.
excel_vb_record_stop
Now 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 Modules folder. Under that folder you will be able to open your script for editing.
excel_vb_rec_edit

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’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!

Permanent link to this article: http://sanuja.com/blog/visual-basic-script-using-the-interface