Creating a Userform

UserForms combine the capabilities of InputBox and MsgBox to create a more efficient way of interacting with the user. For example, rather than have the user fill out personal information on a sheet, you can create a UserForm that prompts for the required data (see Figure 9.3).

Figure 9.3

You can create a custom userform to get more information from the user.

Figure 9.3

You can create a custom userform to get more information from the user.

Insert a UserForm in the VBE by choosing Insert, UserForm from the main menu. A UserForm module is added to the Project Explorer, a blank form appears in the window where your code usually is, and the Controls Toolbox appears (see Figure 9.4).

Figure 9.4

Preliminary userform and toolbox.

Figure 9.4

Preliminary userform and toolbox.

You can resize the form by grabbing and dragging the handles on the right side, bottom edge, or lower right corner of the UserForm. To add controls to the form, click on the desired control in the toolbox and draw it on the form. Controls can be moved and resized at any time.

¡¡j The toolbox, by default,displays the most common controls.To access more controls,right-click on S the toolbox and select Additional Controls.

0 0

Post a comment