Phone (01457) 858877 or email
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).
This blog is part of our Excel VBA tutorial series. We also run training classes in Excel and courses in VBA.
A UserForm (or just form) is a dialog box that you create yourself. You've almost certainly already seen some pre-created forms in Visual Basic for Applications:
|
|
| A message box | An input box |
However,neither of these can be customised much. A UserForm, by contrast, can have lots of widgets and formatting on it:

This user form allows someone in your office to order a drink.
UserForms aren't limited to Excel: Word, PowerPoint and SharePoint Designer use the same software (although Access and Outlook, typically, do their own thing).
Should you learn to create and use UserForms? Have a look at the pros and cons below, and make up your own mind! Let's start with the good things:
| Advantage | Notes |
|---|---|
| Impressiveness | There's nothing like a custom form laden with drop down lists, command buttons, pictures and formatting to impress a client or manager. |
| Ease of use | For people who don't enjoy inputting data directly into Excel, you can create a front-end form instead and make it as easy to use as possible. |
Those are powerful advantages; how about the other side of the coin?
| Disadvantage | Notes |
|---|---|
| Validating data | Creating user forms is easy; making sure that users input data correctly takes longer. On a worksheet you can use tools like data validation and protection to ensure users enter the right type of data, but in a form you're going have to work much harder to avoid errors. |
| Flakiness | My experience from many years of training on Excel and writing systems is that user forms occasionally crash - Excel itself rarely does. |
Now that you know what a form is, let's look at how to create one, and how to attach macros to it.
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).
This blog is part of our Excel VBA tutorial series. We also run training classes in Excel and courses in VBA.
Comments on this blog
This blog currently has no comments.