Microsoft Office Tutorials and References
In Depth Information
Lesson 18: Creating UserForms
In previous lessons, you have seen examples of how your workbook can interact with its users
to make decisions by employing such methods as InputBoxes and Message Boxes. Although
these interactive tools are very useful for the situations they are meant to serve, they have
limited usefulness in more complex applications.
Some of your projects will require a more versatile approach to asking for and gathering many
kinds of information from the users, all within a dedicated interface that’s convenient and
easy to use. Perhaps you have seen attempts to accomplish this on a neatly arranged worksheet
where certain cells are color-shaded or unprotected for data input, maybe with drop-down
lists and embedded check boxes or option buttons. A UserForm in VBA is a more efficient
method for collecting and recording such information.
WHAT is A usErforM?
A UserForm is essentially a custom-built dialog box, but that description does not do justice
to the immense complexity and diversity with which UserForms can be built and be made to
function. A UserForm is created in the Visual Basic Editor, with controls and associated VBA
code, usually meant for the end user to be advised of some information or to enter data,
generate reports, or perform some action.
Think of UserForms as electronic versions of the different forms you ill out on
your computer, such as when you make an online purchase, or with paper and
pen in a business office. Some information on most forms is required and some
information is optional. A UserForm is a dynamic object, with VBA code
working behind the scenes to guide your users toward telling your workbook what it
needs to know.