Excel 2019 Bible

(singke) #1

Part VI: Automating Excel


you need some method of asking the user what type of change to make to the cells. The
solution is to present a dialog box like the one shown in Figure 44.1. This dialog box is a
UserForm that was created by using the Visual Basic Editor (VBE), and it’s displayed by a
VBA macro.

FIGURE 44.1
A UserForm that asks the user to select an option

Another solution is to develop three macros—one for each type of text case change.
Combining these three operations into a single macro and using a UserForm is a more effi-
cient approach, however. We discuss this example, including how to create the UserForm, in
“Seeing Another UserForm Example,” later in the chapter.

Exploring UserForm Alternatives


After you get the hang of it, developing UserForms isn’t difficult. But sometimes using the
tools that are built into VBA is easier. For example, VBA includes two functions (InputBox
and MsgBox) that enable you to display simple dialog boxes without having to create a
UserForm in the VBE. You can customize these dialog boxes in some ways, but they cer-
tainly don’t offer the number of options that are available in a UserForm.

Using the InputBox function
The InputBox function is useful for obtaining a single input from the user. A simplified
version of the function’s syntax follows:
InputBox(prompt[,title][,default])
Free download pdf