Part A: Introduction to Excel VBA
In this Part you will learn …
- why use Excel VBA
- the Visual Basic Editor
|
The purpose of this course is to show Excel users how to use the Visual Basic For Application programming language that comes free with MS Excel. This tool will help you to significantly enhance the power of the world’s most popular spreadsheet. Using VBA, however, involves programming, simple but very powerful. Nowadays computer programming has become much easier, and even so-called normal people now engage in this activity. Programming simply means developing instructions that the computer automatically carries out. Excel programming means that you can instruct Excel to automatically do things that you normally do manually — saving you lots of time resources. Since you’re reading this, it’s a safe bet that you need to become an Excel programmer. This could be something you initiated or you want to make yourself more marketable. In this online course, we will learn about Excel programming so that by the time you finish this course, you can honestly say, “Oh, Excel programming is so easy.” At the end of this course, we will also learn develop a few simple applications with Excel VBA. Before learning how to program in VBA, you have to learn how to use the software required for creating your projects. The VBA development software is included with each component of the Microsoft Office suite of programs, 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.
|
| (a) Menu Bar Just like any other program menu bar that you have used, the VBE menu bar contains various commands and components. You can use this commands and components in the VBE to do things. Many of the menu commands have shortcut keys associated with them.
|
Figure 1.2 is the VBE program window. There are a few components on this window.
(b) Project Explorer
(Figure
1.3)
|
The Project Explorer window displays a tree diagram that shows every workbook currently open in Excel (including add-ins and hidden workbooks). When you’re working in the VBE, each Excel workbook and add-in that’s open is a project. You can think of a project as a collection of objects arranged as an outline. Click on the plus sign (+) at the left of the project’s name in the Project Explorer window to expand a project.
|
| (d) Object Browser The VBE includes another tool, known as the Object Browser (Figure 1.5). This tool allows you browse through the objects available to you. To access the Object Browser, press F2 when the VBE is active (or choose View ➪ Object Browser). You see a window like the one shown in Figure 1.5. The drop-down list at the top contains a list of all currently available object libraries. Figure 1.5 shows All Libraries. If you want to browse through Excel’s objects, select Excel from the drop-down list.
|
(Figure 1.5)
(e) Properties Window
(Figure 1.6)
|
Figure 1.6 show the Properties window of the CommandButton1.For example when you change the Caption property to of CommandButton1 to “Click Me” and then notice how the new caption is displayed on the control. You can also play with some of the other properties such as Font, Height, BackColor, Width, and Height to change the appearance of CommandButton1.
For users of Excel 2007 ONLY, they need to install VBA for Excel 2007 from your Office CD. Users of earlier versions of Excel need not do so. In the new version of Excel in 2007 the user needs to install VBA for Excel to be able to develop, maintain or modify macros. This is the steps on how to do it : i.. Click on the "Start" button at the bottom of your screen and chose "Control Panel" then "Add or Remove Programs" ![]()
ii. Select "Microsoft Office" from the list of programs and click on “Change”
iii. Select "Add or Remove Features" and click on "Continue"
iv. Expand "Office Shared Features" with the + sign
v. Select "VBA for Application" and click on "Continue"
vi. After the installation you can now use VBA for Excel 2007. vii. Next you need to show the "Developer" item on your toolbar. To
do so click on the Office button: You should now see a new item on your Excel menu bar "Developer" and you can develop macros when you are ready. viii. Lastly, set the security level of Excel so that you can use macros. To do so, click on the "Developer" menu item and click on the "Macro Security" button in the ribbon. Check the second level "Disable all Macros with Notification" and you are set.
2) Summary: I hope that in this Part A, you did get a basic introduction to the VBA programming environment. So, you’ve learn how to access the VBA IDE and how to view and use some of its major components. |
Previous | Back to Home | Back to TOC | Next