Next
VBA an Overview
Programming simply means writing instructions that are automatically carried out by the computer. The same goes for Visual Basic for Application (VBA) which is a programming language and can be used with MS Excel, MS Word, MS Powerpoint for writing programs to use the hidden features which are not available simply. Use of VBA helps to significantly enhance the power of the above mentioned office software’s in our case MS Excel through a simple yet powerful programming.
Programming in Excel means giving instructions to Excel to automatically do things that done manually and in lot of cases can’t be done manually. This helps in saving lots of time and also in exploiting the features of Excel.
Every programming language has a development environment and the same goes for Excel VBA. So to learn to program in a particular language it is necessary to know the in an out of the environment in which it is developed.
The VBA development software is included with each component of the MS Office, including Excel. Starting the VBA development software places you in the VBA programming environment IDE, which provides you with a number of tools for use in the development of your project. The environment for VBA is called Visual Basic Editor (VBE)
Visual Basic Editor
Visual Basic Editor is a separate application where VBA programs can be written and if need be edited. It works seamlessly with Excel. You can activate the VBE by using the Tool-Macro-Visual Basic Editor command as shown in figure below or by pressing Alt+F11 when Excel is active If Alt+F11 is pressed again then we return back to Excel.
Figure below shows the VBE program window:
The various components of VBE are:
Menu Bar
Just like any other program menu bar VBE menu bar contains various commands and components which can be used to perform various tasks. Like other menu bars in VBE also many of the menu commands have shortcut keys associated with them.
Project Explorer
Figure below shows the Project Explorer window in VBE
The Project Explorer window displays a tree diagram that shows every workbook currently open in Excel (including add-ins and hidden workbooks). Each Excel workbook and add-in that is open is shown as a project in VBE, where a Project is a collection of objects arranged as an outline. Clicking on the (+) sign will expand a project.
Code Window
The code written in VBA is contained in the Code window as shown in the Figure below. Sometimes it is also known as a Module window. Every object (e.g. Sheet 1) in a project has an associated Code window. Double-click the object in the Project Explorer window to bring up the Code Window e.g. to view the Code window for the Sheet1 object; double-click Sheet1 in the Project Explorer window. If no code is added then the Code window will be empty.