How to create my user form?
To be able to create your first form in Excel from header to VBA editor. Click the Developer tab and select the Visual Basic option or use the shortcut command Alt + F11.
The VBA editor window opens, to add a new module click on the menu Enter and then UserForm. When created, the new form automatically appears in a container folder with the default name. There you have to host all the files you need as well as the new modules related to that project you just created.
A floating box with a group of controls also appears. Those controls you can add on the UserForm. Both the objects you add and the User forms have their own properties, methods and events that you can change their appearance and behavior.
The properties box appears just below the box where the containing folder is located. Otherwise, press F4. The box contains the properties on the right side and the property name on the left side.
Set initial properties
With the form created, it is necessary change the initial properties. Change the name of the module, choose the background colors, choose the font and also what its position will be.
You can do it in design mode or by code, where you change properties by entering the object name, followed by a period, the property name, an equal sign =, and the property value.
UserForm controls
The Toolbox or UserForm controls are the toolbar that you can add to the form by clicking and dragging objects within the User Form in the desired location.
- Label: it is used to insert a text that serves as a reference for the end user. It is generally used to identify other controls.
- TextBox: used for allow the user to enter data to perform an operation or to archive it. The text placed there can be edited.
- CommandButton (Button): as the name suggests, it is a button and is used to start a specific process or action.
- ComboBox (combo box): this control is used to view multiple items from a list, but the end user will only be able to choose one.
- ListBox: a control used to add multiple items to a list so that the end user can choose one or more.
- OptionButton: used to create multiple options where the end user will only be able to select one.
- CheckBox (checkboxes): Control used to validate Boolean information, i.e. it is only possible to have an answer between true and false.
- Image: used to add images to the form.
- Frame: this type of control is used to organize the controls within the form. Commonly used to group buttons, but you can also control the appearance of the controls it contains, such as the font.
- MultiPage: this control adds multiple pages to a form. In turn, each form can contain a group of controls.
- ScrollBar - Allows quick scrolling of a list of items.
- SpinButton (spin button): this is a two-arrow control that allows the end user to select a value by clicking the arrows.