In This Chapter
- Creating, showing, and unloading UserForms
- Exploring the UserForm controls available to you
- Setting the properties of UserForm controls
- Controlling UserForms with VBA procedures
- Creating a UserForm
- Introducing the types of events relevant to UserForms and controls
- Customizing your control Toolbox
- Going over a handy checklist for creating UserForms
How Excel Handles Custom Dialog Boxes
Excel makes creating custom dialog boxes for your applications relatively easy. In fact, you can duplicate the look and feel of many of Excel’s dialog boxes. A custom dialog box is created on a UserForm, and you access UserForms in Visual Basic Editor (VBE).
Following is the typical sequence that you’ll follow when you create a UserForm:
- Insert a new UserForm into your workbook’s VB Project.
- Add controls to the UserForm.
- Adjust some of the properties of the controls that you added.
Write event-handler procedures for the controls.
These procedures, which are located in the code window for the UserForm, are executed when various events (such as a button click) occur.
Write a procedure that will display the UserForm.
This procedure will be located in a standard VBA module (not in the code module for the UserForm).
Add a way to make it easy for the user to execute the procedure you created in Step 5.
You can add a button to a worksheet, create a shortcut menu command, and so on.
Inserting a New UserForm
To insert a new UserForm, activate VBE (press ...