WiseOwl Training - Established 1992 Wise Owl Training

Established May 1992
30 years in business
Wise Owl Training
30 years in business
See 525 reviews for our classroom and online training
Drawing UserForms in the VBA code editor
Part two of a seven-part series of blogs

Learn how to create your own custom dialog boxes in VBA, using UserForms. This is the first part of a three-part series (the other parts are on Writing Code for UserForms and Creating Advanced Controls).

  1. An Introduction to UserForms in VBA
  2. Creating and Using UserForms in VBA (this blog)
  3. The Properties Window
  4. Selecting Forms and Controls
  5. Formatting Forms and Controls
  6. Grouping, Aligning, Sizing, Spacing and Arranging
  7. Controlling How Form Keys Work

This blog is part of our Excel VBA tutorial series.  We also run training classes in Excel and courses in VBA.

Posted by Andy Brown on 28 February 2012

You need a minimum screen resolution of about 700 pixels width to see our blogs. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

Creating and Using UserForms in VBA

Creating a Form

It's easy enough to create a user form in VBA - within the code editor, just right-click and choose to add a user form:

Inserting a user form

Right-click in a project/workbook and choose the option shown to insert a user form.


You'll be shown a rectangular form, which you can resize using the bottom right corner:

Resizing a form

Click and drag on the bottom right corner to resize a user form - it will always appear at the top left corner of the code editor window.


Just like macros, a user form is stored as part of a workbook, rather than in a separate file.


The things that you add to a user form are called controls.  The following simple form has 3 controls:

Form with 3 controls

This form has 1 label, 1 textbox and 1 command button.


The following drinks order form has more than 10 controls:

Drinks form, showing controls

This relatively simple form contains:


A later blog in this series shows how to add some of the more esoteric controls - for now, we'll stick to general principles.

Drawing Controls on a Form

You can draw any control on a form using the Toolbox:

The toolbox

The form Toolbox - the simplest controls are shown at the top left.


If you can't see your Toolbox window when you have a form open, try clicking on the Toolbox tool:

Toolbox tool

Click on the tool shown to display the Toolbox, if it's gone AWOL.

Once you've chosen your control tool, you can click and drag on your form where you want it to go:

Drawing a label control

Here the mouse pointer shows that you are drawing a Label control.


It's often easier just to click where you want a control to go, and Excel (or any other application) will draw it with a standard size and shape.

Having learnt how to draw controls, let's move on to how to show their properties.


This blog has 0 threads Add post