Adding controls
UserForms with meaningful names and customized background colors are still not worth much. We need to add controls to bring life to the form, or at least to make it useful. After all, if we want to populate a spreadsheet by using a dialog box, there must be someplace for us to enter that data on the form. Furthermore, it would be nice to have some controls or buttons to cancel the entry or save it.
In this recipe, we will be adding controls to a UserForm.
Getting ready
Make sure that UserForms.xlsm
is still open. UserForm1 should be visible, and both the Project Explorer and the Properties window should be visible on the left of the VBA Editor.
How to do it…
Let's do the following exercise:
- Make sure that the UserForm is selected, then click the Toolbox icon on the standard toolbar to open the Toolbox window.
- On the Toolbox windows, click the Label control:
- Click once...