Inserting the form
Unlike macros, UserForms are not created in newly inserted modules. They live elsewhere, which is what we're going to work on now.
In this recipe, we will be inserting a UserForm in the VBA Editor.
Getting ready
Open Excel and activate a new workbook. Save the file as a macro-enabled file on your desktop and call it UserForms.xlsm
. Sheet1 should be active.
How to do it…
Let's insert our first UserForm using the following steps:
- Enter the following data into Sheet1. We will be creating a form to later add more data to this list:
- Press Alt + F11 to switch to the VBA Editor.
- Right-click somewhere in the Project Explorer. From the pop-up menu that appears, select Insert, then click on UserForm:
- A blank UserForm1 window will appear to the right, and an icon for UserForm1 will appear in the Project Explorer: