Chapter 18

UserForm Techniques and Tricks

In This Chapter

arrow Using a custom dialog box in your application

arrow Creating a dialog box: a hands-on example

The previous chapters show you how to insert a UserForm (which contains a custom dialog box), add controls to the UserForm, and adjust some of the control’s properties. These skills, however, won’t do you much good unless you understand how to make use of UserForms in your VBA code. This chapter provides these missing details and presents some useful techniques and tricks in the process.

Using Dialog Boxes

When you use a custom dialog box in your application, you normally write VBA code that does the following:

check.png Initializes the UserForm controls. For example, you may write code that sets the default values for the controls.

check.png Displays the dialog box by using the UserForm object’s Show method.

check.png Responds to the events that occur for the various controls — such as clicking a CommandButton.

Validates the information provided by the user (if the ...

Get Excel VBA Programming For Dummies, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.