VISUAL BASIC FOR APPLICATIONS WITH EXCEL 1
VISUAL BASIC FORAPPLICATIONS WITH
EXCEL
1
To install or enable VBA:
1.Double-click the Add/Remove Programs icon in the Microsoft Windows Control Panel (found on the Start menu).
2.If you installed Excel as part of Microsoft Office, click Microsoft Office (edition and version)
3.In the currently installed programs box, and then click the Change button. If you installed Excel individually, click Excel (edition and version) in the currently installed programs box, and then click the Change button.
4. On the installation options screen in the Setup program, click the plus sign (+) next to Office Shared Features.
5. Select Visual Basic for Applications, click the arrow next to your selection, and then click
6. Run from My Computer.
2
After the installation is complete, you may also need to change the macro security setting in Excel before you can run any VBA programs. To change the macro security setting in Excel 2007, do the following:
1. Click the Office button, and then click the Excel Options button. Click the Trust Center button from the left-hand navigation menu, and then click the Trust Center Settings button, which opens the Trust Center window.
2. From the Trust Center window, click the Macro Settings icon from the left-hand navigation Menu and choose the Disable All Macros with Notification option.
3.After the installation is complete, you may also need to change the macro security setting in excel before you can run any VBA programs. To change the macro security setting in Excel 2007, do the following:
5. Click the Office button, and then click the Excel Options button. Click the Trust Center button from the left-hand navigation menu, and then click the Trust Center Settings button, which opens the Trust Center window.
6. From the Trust Center window, click the Macro Settings icon from the left-hand navigation Menu and choose the Disable All Macros with Notification option.
3
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
Getting to the IDE from Excel :
IDE can be acced from Excel through the keystroke Alt + F11 or via the Developer tab located in the Excel Ribbon as shown in Figure
Microsoft Office button
Launch the Visual Basic Editor
The RibbonAccessing the VBA
IDE from the
Ribbon’s
Developer tab.
4
If you do not see the Developer tab in the Ribbon, you will need to change an Excel option by completing the next set of steps.
1. Click the Office button, and then click the Excel Options icon.
2. Click the Popular icon from the left-hand navigation menu and choose Show Developer.
5
The menu bar
The Standard toolbar
The Project Explorer window
The Properties window
An ObjectCode window
Figure 1.3 shows that there is currently one project, calledBook1, open, and that this project contains four Excel objects: Sheet1, Sheet2, Sheet3, and This Workbook
6
The Sheet1 selection
The Name property
7
An editedworksheet namein Excel.
8
Working withForm and ActiveXcontrols.
9
Manage control propertieswhile in Design Mode
The Command Button control placed on a worksheet.
10
Click to access the Properties window
Displays the selectedcontrol’s properties
11
The Object List
The Procedure List
The Editor
12