Page 31 - Excel 2007 Bible
P. 31
02_044039 ftoc.qxp 11/21/06 10:53 AM Page xxx
Contents
Chapter 40: Creating Custom Worksheet Functions . . . . . . . . . . . . . 703
Overview of VBA Functions ......................................................................................................703
An Introductory Example..........................................................................................................704
A custom function ..........................................................................................................704
Using the function in a worksheet ..................................................................................704
Analyzing the custom function........................................................................................705
About Function Procedures ......................................................................................................705
Executing Function Procedures ................................................................................................706
Calling custom functions from a procedure ....................................................................706
Using custom functions in a worksheet formula..............................................................707
Function Procedure Arguments ................................................................................................707
A function with no argument ..........................................................................................708
A function with one argument ........................................................................................708
Another function with one argument ..............................................................................708
A function with two arguments ......................................................................................710
A function with a range argument ..................................................................................710
Debugging Custom Functions ..................................................................................................711
Inserting Custom Functions ......................................................................................................712
Learning More ..........................................................................................................................713
Chapter 41: Creating UserForms . . . . . . . . . . . . . . . . . . . . . . . 715
Why Create UserForms?............................................................................................................715
UserForm Alternatives ..............................................................................................................716
The InputBox function....................................................................................................716
The MsgBox function......................................................................................................717
Creating UserForms: An Overview ............................................................................................720
Working with UserForms................................................................................................720
Adding controls ..............................................................................................................721
Changing the properties of a control ..............................................................................722
Handling events..............................................................................................................723
Displaying a UserForm....................................................................................................724
A UserForm Example ................................................................................................................724
Creating the UserForm....................................................................................................724
Testing the UserForm......................................................................................................725
Creating an event-handler procedure ..............................................................................726
Another UserForm Example......................................................................................................726
Creating the UserForm....................................................................................................727
Testing the UserForm......................................................................................................728
Creating event-handler procedures ................................................................................729
Testing the UserForm......................................................................................................730
Making the macro available from a worksheet button ....................................................731
Making the macro available on your Quick Access Toolbar ............................................731
More on Creating UserForms ....................................................................................................732
Adding accelerator keys ..................................................................................................732
Controlling tab order ......................................................................................................732
Learning More ..........................................................................................................................732
xxx