Why Create User Forms

Some of the VBA macros you create behave the same every time you execute them. For example, you may develop a macro that enters a list of your employees into a worksheet range. This macro always produces the same result and requires no additional user input.

You might develop other macros, however, that behave differently under various circumstances or that offer the user options. In such cases, the macro may benefit from a custom dialog box. A custom dialog box provides a simple means for getting information from the user. Your macro then uses that information to determine what it should do.

UserForms can be quite useful, but creating them takes time. Before I cover the topic of creating UserForms in the next chapter, you need to know about some timesaving alternatives.

VBA lets you display four different types of dialog boxes that you can sometimes use in place of a UserForm. You can customize these built-in dialog boxes in some ways, but they certainly don't offer the options available in a UserForm. In some cases, however, they're just what the doctor ordered.

In this chapter you read about

^ The MsgBox function ^ The InputBox function ^ The GetOpenFileName method ^ The GetSaveAsFileName method

I also describe how to use VBA to display the Excel built-in dialog boxes — the dialog boxes that Excel uses to get information from you.

0 0

Post a comment