Top Banner
VISUAL BASIC FOR APPLICATIONS WITH EXCEL 1
12
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: VBA

VISUAL BASIC FORAPPLICATIONS WITH

EXCEL

1

Page 2: VBA

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

Page 3: VBA

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

Page 4: VBA

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

Page 5: VBA

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

Page 6: VBA

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

Page 7: VBA

The Sheet1 selection

The Name property

7

Page 8: VBA

An editedworksheet namein Excel.

8

Page 9: VBA

Working withForm and ActiveXcontrols.

9

Page 10: VBA

Manage control propertieswhile in Design Mode

The Command Button control placed on a worksheet.

10

Page 11: VBA

Click to access the Properties window

Displays the selectedcontrol’s properties

11

Page 12: VBA

The Object List

The Procedure List

The Editor

12