Excel Reference

Create a Custom Dialog Box

Direct Answer

Create a Custom Dialog Box
is part of the Excel VBA object model. This reference page documents its syntax, parameters, and typical usage.

Reference

Use the following procedure to create a custom dialog box:

1. Create a User Form

On the Insert menu in the Visual Basic Editor, click UserForm.

2. Add Controls to a User Form

Find the control you want to add in the Toolbox and drag the control onto the form.

3. Setting Control Properties

Right-click a control in design mode and click Properties to display the Properties window.

4. Initializing Control Properties

You can initialize controls in a procedure before you show a form, or you can add code to the Initialize event of the form.

5. Control and Dialog Box Events

All controls have a predefined set of events. For example, a command button has a Click event that occurs when the user clicks the command button. You can write event procedures that run when the events occur.

6. Displaying a Custom Dialog Box

Use the Show method to display a UserForm.

7. Using Control Values While Code Is Running

Some properties can be set at run time. Changes made to the dialog box by the user are lost when the dialog box is closed.

!include[Support and feedback]

Reference: Excel object-model documentation • updated 06/08/2017
. Rebuilt for readability; see the original for complete parameter matrices.