| |
Page |
Introduction |
1 |
| What is a Macro? |
1 |
| Recording a Macro |
1 |
| Running a Macro |
2 |
| Relative References |
2 |
Assigning Macros |
3 |
| Assigning a Macro to a Button on a Toolbar |
3 |
| Assigning a Macro to a Menu Item |
6 |
| Assigning a Macro to a Button on a Sheet |
7 |
| Assigning a Macro to a Drawn Object on a Sheet |
7 |
| Exercise 1 |
8 |
| Answers to Exercise 1 |
8 |
Editing Macros |
9 |
| Visual Basic Editor |
9 |
| Procedures |
11 |
| Inserting Comments |
11 |
| Printing a Visual Basic Module |
12 |
| Exercise 2 |
13 |
| Answers to Exercise 2 |
13 |
The Range Object |
15 |
| Introduction |
15 |
| Cells Property |
15 |
| Range Property |
15 |
| Flexible Ranges |
16 |
| Range Contents |
20 |
| Exercise 3 |
22 |
| Answers to Exercise 3 |
22 |
Workbooks and Sheets |
23 |
| Activating a Workbook |
23 |
| Activating a Worksheet |
23 |
| ThisWorkBook |
23 |
Objects, Properties and Methods |
25 |
| Introduction |
25 |
| Objects |
25 |
| Controlling Objects with their Properties |
27 |
| Performing Actions with Methods |
27 |
| Exercise 4 |
30 |
| Answers to Exercise 4 |
30 |
Variables and Constants |
31 |
| Variables |
31 |
| Data Types |
32 |
| Constants |
36 |
| Exercise 5 |
38 |
| Answers to Exercise 5 |
39 |
Control Structures |
40 |
| Conditional Control Structures |
40 |
| Looping Control Structures |
42 |
| Non-Structured Statements |
45 |
| Sub Procedures |
46 |
| Exercise 6 |
48 |
| Answers to Exercise 6 |
49 |
Controls, Dialog Boxes and Forms |
52 |
| Introduction |
52 |
| Built-In Dialog Boxes |
52 |
| Predefined Dialog Boxes |
52 |
| User-Defined Forms |
56 |
| Worksheet Forms |
56 |
| Visual Basic Forms |
59 |
| Handling Form Controls |
62 |
| Exercise 7 |
64 |
| Answers to Exercise 7 |
64 |
Registry, Files and Closed Workbooks |
65 |
| Storing Information |
65 |
| Closed Workbooks |
66 |
Command Bars |
67 |
| About Toolbars and Menus |
67 |
| Command Bars in Workbooks |
67 |
| Exercise 8 |
70 |
Display |
71 |
| ScreenUpdating |
71 |
| DisplayAlerts |
71 |
Debugging and Error trapping |
73 |
| Debugging Basics |
73 |
| Break Mode |
75 |
| Watching Variables |
76 |
| Immediate Window |
77 |
| Error Handling |
78 |
Worksheet and Workbook Events |
81 |
| Worksheet Object Events |
81 |
| Workbook Object Events |
81 |
Function Procedures |
83 |
| Introduction |
83 |
| User-Defined Functions |
83 |
| Exercise 9 |
85 |
| Answers to Exercise 9 |
85 |
Add-in Applications |
87 |
| Creating an Add-In |
87 |
| Converting
an Add-In to a Workbook |
89 |
| Exercise 10 |
90 |
Macro Security |
91 |
| Introduction |
91 |
| Setting the Macro Security Level |
91 |
| Digital Signatures |
92 |
Appendix A Naming Conventions |
95 |
| User Form Controls |
95 |
| Memory Variables |
95 |