Excel 2010 Bible

(National Geographic (Little) Kids) #1

Chapter 41: Creating UserForms


843



  1. Activate the VB Editor and insert a new UserForm.

  2. Add the appropriate controls to the UserForm.

  3. Create a VBA macro to display the UserForm. This macro goes in a normal VBA
    module.

  4. Create event handler VBA procedures that are executed when the user manipulates
    the controls (for example, clicks the OK button). These procedures go in the code
    module for the UserForm.


The following sections provide more details on creating a UserForm.

Working with UserForms

To create a dialog box, you must first insert a new UserForm in the VB Editor window. To activate
the VB Editor, choose Developer ➪ Visual Basic (or press Alt+F11). Make sure that the correct
workbook is selected in the Project window and then choose Insert ➪ UserForm. The VB Editor
displays an empty UserForm, shown in Figure 41.6. When you activate a UserForm, the VB editor
displays the Toolbox, which is used to add controls to the UserForm.

FIGURE 41.6

An empty UserForm.


Adding controls

The Toolbox, also shown in Figure 41.6, contains various ActiveX controls that you can add to
your UserForm.
Free download pdf