An Overview of Creating UserForms in Excel 2016 VBA - dummies

An Overview of Creating UserForms in Excel 2016 VBA

By John Walkenbach

In VBA, the official name for an Excel dialog box is a UserForm. But a UserForm is really an object that contains what’s commonly known as a dialog box. This distinction isn’t important, so many programmers use these terms interchangeably.

When creating a UserForm, you usually take the following general steps:

  1. Determine how the dialog box will be used and at what point it will be displayed in your VBA macro.

  2. Press Alt+F11 to activate the VBE and insert a new UserForm object.

    A UserForm object holds a single UserForm.

  3. Add controls to the UserForm.

    Controls include items such as text boxes, buttons, check boxes, and list boxes.

  4. Use the Properties window to modify the properties for the controls or for the UserForm itself.

  5. Write event-handler procedures for the controls (for example, a macro that executes when the user clicks a button in the dialog box).

    These procedures are stored in the Code window for the UserForm object.

  6. Write a procedure (stored in a VBA module) that displays the dialog box to the user.