Create An Excel UserFormF
Create An Excel UserFormF
search
Introduction to UserForms
Introduction to UserForms
To create a UserForm requires some programming, and you can see the steps in the videos shown
below. For the written instructions, look below the videos.
In this example, inventory data is stored on a hidden worksheet, where it is protected from accidental
damage or deletion. Users enter inventory data by opening the UserForm, filling in the boxes, and
clicking a button.
http://www.contextures.com/xlUserForm01.html[21-Mar-18 11:03:07]
Create an Excel UserForm
In the videos, Excel 2003 is used, and the same steps can be followed in later versions. When saving
the file in Excel 2007 or later, save as a macro-enable file type.
Users will be able to type data into the text boxes. Labels are added beside the text boxes, to describe
what users should enter into the text box
http://www.contextures.com/xlUserForm01.html[21-Mar-18 11:03:07]
Create an Excel UserForm
With buttons on the UserForm, a user can click to make something happen. For example, click a
button after entering data in the text boxes, when you're ready to move the data to the worksheet
storage area.
The VBA code runs when a specific event occurs, such as clicking a button, or entering a combo box.
In this example, the user will click a button, and the VBA code will move the data to the worksheet
storage area.
http://www.contextures.com/xlUserForm01.html[21-Mar-18 11:03:07]
Create an Excel UserForm
Create a UserForm
UserForms are created in the Visual Basic Editor.
1. To open the Visual Basic Editor, hold the Alt key, and press the F11 key
2. Choose View | Project Explorer, to see a list of projects. (Usually, this is displayed at the left side
of the VBE window.)
3. In the Project Explorer, select the PartLocDB project.
4. From the menu bar, choose Insert | UserForm
5. A blank UserForm appears, and the ToolBox should open. (If the ToolBox doesn't appear,
choose View | Toolbox)
http://www.contextures.com/xlUserForm01.html[21-Mar-18 11:03:07]
Create an Excel UserForm
4. The form name will change in the Project Explorer, but the form still shows UserForm1 in its
title bar.
5. In the Properties window, double-click on the Caption property-- UserForm1.
6. Type: Parts Inventory
and press the Enter key
7. The title bar will display the new caption.
2. On the UserForm, click near the top centre, to add a standard sized textbox.
3. With the new textbox selected, double-click on the Name property in the Properties window.
4. Type: txtPart
and press the Enter key
5. Click on an empty part of the UserForm, to select the UserForm and to display the Toolbox.
http://www.contextures.com/xlUserForm01.html[21-Mar-18 11:03:07]
Create an Excel UserForm
2. On the UserForm, click to the left of the textbox, to add a standard sized label.
3. With the new label selected, double-click on the Caption property in the Properties window.
4. Type: Part
and press the Enter key
5. If necessary, you can resize the label, so it doesn't cover the textbox -- point to the handle on its
right border, and drag to the left.
6. Click on an empty part of the UserForm, to select the UserForm and to display the Toolbox.
http://www.contextures.com/xlUserForm01.html[21-Mar-18 11:03:07]
Create an Excel UserForm
2. On the UserForm, click at the bottom left, to add a standard sized CommandButton.
3. With the new CommandButton selected, double-click on the Name property in the Properties
window.
4. Type: cmdAdd
and press the Enter key
5. With the new CommandButton selected, double-click on the Caption property in the Properties
window.
6. Type: Add this part
and press the Enter key
7. Click on an empty part of the UserForm, to select the UserForm and to display the Toolbox.
8. Repeat the above steps to add a CommandButton named cmdClose, with a label Close
9. If required, you can reposition the buttons by dragging them to a new location on the
UserForm.
http://www.contextures.com/xlUserForm01.html[21-Mar-18 11:03:07]
Create an Excel UserForm
End Sub
http://www.contextures.com/xlUserForm01.html[21-Mar-18 11:03:07]
Create an Excel UserForm
4. Where the cursor is flashing, paste the highlighted code from the following sample
Now, if someone clicks the X in the UserForm, they'll see your message.
http://www.contextures.com/xlUserForm01.html[21-Mar-18 11:03:07]
Create an Excel UserForm
1. Click on an empty part of the UserForm, to select the UserForm and to display the Toolbox.
2. On the Menu bar, choose Run | Run Sub/UserForm.
If the tab order was incorrect (e.g. when you pressed the tab key you moved to the wrong textbox or
button), you can change it
http://www.contextures.com/xlUserForm01.html[21-Mar-18 11:03:07]
Create an Excel UserForm
An Excel UserForm course is also available -- Learn Excel UserForms for Data Entry
http://www.contextures.com/xlUserForm01.html[21-Mar-18 11:03:07]
Create an Excel UserForm
Search
Custom Search
Related Tutorials
UserForm with ComboBoxes
http://www.contextures.com/xlUserForm01.html[21-Mar-18 11:03:07]
Create an Excel UserForm
http://www.contextures.com/xlUserForm01.html[21-Mar-18 11:03:07]
Create an Excel UserForm
http://www.contextures.com/xlUserForm01.html[21-Mar-18 11:03:07]
Create an Excel UserForm
Privacy Policy
Debra Dalgleish
http://www.contextures.com/xlUserForm01.html[21-Mar-18 11:03:07]