O'Reilly logo

Excel VBA Programming For Dummies, 3rd Edition by John Walkenbach

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required