Professional Documents
Culture Documents
Create Excel UserForms For Data Entry in 6 Easy Steps - Tutorial and Practical Example
Create Excel UserForms For Data Entry in 6 Easy Steps - Tutorial and Practical Example
Create Excel UserForms For Data Entry in 6 Easy Steps - Tutorial and Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
Message boxes.
Input boxes.
The GetOpenFilename method.
The GetSaveAsFilename method.
The FileDialog method.
Excel worksheets.
UserForms.
“ Dialog boxes and forms are among the most powerful and feature-packed elements of VBA.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 1/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
In this UserForms Tutorial, you nd all the information you need to start creating your own UserForms in
START
Excel. LEARNING
This blog postEXCEL VBA as follows:
is organized EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
This Tutorial is accompanied by an Excel workbook example that allows you to follow each of the steps I
• A worksheet formula template/example; and
describe in the second section. You can get immediate free access to this workbook by clicking the button
below. • A VBA code snippet/example.
What Is A UserForm
Why Work With UserForms
How To Create An Excel UserForm: Overview
How To Insert A New UserForm
How To Add Controls To A UserForm With The Toolbox
The Toolbox
Group #1: Controls That In uence The Appearance Of Your UserForm
Group #2: Controls That Allow Users To Enter Data, Make Selections Or Issue A Command
How To Select, Move Or Resize UserForm Controls And UserForms
The UserForm Grid
The Format Menu Or UserForm Toolbar
How To Customize A UserForm Or Its Controls
UserForm Or Control Properties Vs. Other VBA Properties
The Properties Window
How To Modify Properties With The Properties Window
Why Modify The Name Property Of Your UserForms Or UserForm Controls
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
How To Remove Controls From A UserForm
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
How To Assign VBA Code To A UserForm
OKWith It
What Is A UserForm Code Window And Why You Work
https://powerspreadsheets.com/create-excel-userforms/ 2/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
What Is A UserForm
When working with VBA, you usually use the term “UserForm” to refer to dialog boxes.
A UserForm is an object. This object represents a window or dialog box within Excel's User Interface. By
working with the UserForm object, you can easily create custom dialog boxes. Each of these dialog boxes
you create is held within an UserForm object.
You can think of a UserForm as a blank canvas. Within this canvas, you can place different elements,
known as controls. Controls are, themselves, also objects. UserForm controls are the objects users work
with to provide input through the UserForm.
You can nd a description of the main controls you can work with further below. These controls are
commonly used within Excel built-in dialog boxes. Therefore, once created, the general appearance and
behavior of the custom dialog boxes you create with UserForms is usually like that of Excel's built-in
dialogs.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
https://powerspreadsheets.com/create-excel-userforms/ 3/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
UserForms are very exible. Therefore, you can create very complex and sophisticated UserForms that
STARTa LEARNING
achieve EXCEL VBA
variety of different purposesEXCEL ANDyou
and help VBAinTRAINING
different RESOURCES
scenarios. VBA CODE GENERATOR
More broadly, and in the words of Excel MVP Tom Urtis (in the Excel VBA 24-Hour Trainer):
“ UserForms enable you to interact with your users in ways that you can't when using standard
Message Boxes, InputBoxes, or controls embedded onto your worksheet.
This doesn't mean that UserForms and, more generally, ActiveX controls are perfect or that they should be
your go-to choice. There are some downsides to UserForms. For example, as explained by Excel MVP
Jordan Goldmeier in Advanced Excel Essentials, UserForms can sometimes act unpredictably. Jordan also
explains how differences in factors such as “internal settings and hardware” may result in UserForms
appearing “different across different computers”.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
1. Insert a UserForm. OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
1. Go to the Visual Basic Editor by, for example, using the “Alt + F11” keyboard shortcut.
• A worksheet formula template/example; and
OK
https://powerspreadsheets.com/create-excel-userforms/ 5/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 6/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
2. Do one of the following: Join tens of thousands
ACADEMY LOGIN
Click on the Insert UserForm button in the toolbar.
of Excel Power Users
Get updates and resources to help you be
more efficient and work faster with Excel.
Toolbar and Insert UserForm button
Additionally, (almost) every week I send one
of the following two emails:
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 7/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
A Forms node. If the VBA Project you're working on already contains a Forms node, the VBE doesn't
add it again.
A new UserForm. This UserForm appears within the Forms collection.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 8/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
A UserForm object can hold a single dialog box. Therefore, you must create and insert a new UserForm for
each dialog box you want to create. However, you have signi cant exibility regarding the amount of
UserForms you can store within a single workbook.
Usually, in addition to displaying the new UserForm, the VBE shows a oating window known as the
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
Toolbox. The Toolbox is, also, usually
OK button, displayedthis
(ii) closing/dismissing when
notice you activateto use/browse
or (iii) continuing a UserForm.this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 9/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
BECOME
This Toolbox is the feature you use to add controls to the UserForm ANcreated.
you just EXCELYou
POWER USER
can learn more
about it in the appropriate section below.
If your Visual Basic Editor doesn't display the Toolbox, do either of the following:
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 10/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 11/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
2. Click on the UserForm, in the place where you want to add the control. This results in the created
control having its default size.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 12/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
If you need to add the same control several times to a single UserForm, you can take advantage of a
shortcut by proceeding as follows:
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 13/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
BECOME
4. Click on the Select Objects command in the Toolbox to restore AN EXCEL
the mouse POWER
pointer USER
to Selection mode.
In the example above, I work with a Label. This is only 1 of the different controls you can add to your
UserForms. To better understand the different controls you can add, let's explore…
The Toolbox
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
The Toolbox is a relativelyOK
simple oating window
button, (ii) closing/dismissing thatorallows
this notice youto to
(iii) continuing add ActiveX
use/browse this website.controls to your
UserForms. You work with the Toolbox because the VBE's menu doesn't have commands that allow you to
add UserForm controls. OK
https://powerspreadsheets.com/create-excel-userforms/ 14/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
You rarely need to click on the Select Objects control. This is because Select Objects is the default control
and the mouse pointer usually returns to this mode automatically. According to author Richard Mans eld (in
Mastering VBA for Microsoft O ce 2016), there are 2 common cases where you need to click on the Select
Objects control:
1. If you select a control but change your mind before using it.
2. If you add the same control several times to a single UserForm by using the technique I describe in
the previous section (double-clicking on the control within the Toolbox).
In both cases, you restore the mouse pointer to Selection mode by clicking on Select Objects.
Which controls you choose to add to a UserForm depend on the objective you're trying to achieve. The
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
following sections brie y introduce the 15 controls
OK button, (ii) closing/dismissing that
this notice arecontinuing
or (iii) available in thethis
to use/browse Toolbox.
website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 15/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
2. Frame: Displays a frame where you can enclose other controls. This grouping can be for either
aesthetical or logical purposes. You can, for example, use Frames to (i) group several controls that are
logically related, or (ii) distinguish between different sets of OptionButton controls. Additionally,
Frames allow you to separate different groups of OptionButtons (described in Group #2 below)).
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 16/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 17/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
If you choose to display an Image, consider that Images are stored within the workbook you're using.
Unsubscribe anytime | 100% privacy | Read our Privacy Policy
Therefore, Images can have a substantial in uence on the size of your workbook. Usually, you want to
avoid using (i) too many Images, or (ii) Images that areEnter your email here...
too large.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 18/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
2. ComboBox: Displays a drop-down list, where only 1 item is visible at a given time. Users can use the
START LEARNING
drop-down list EXCEL VBA
to select an item.EXCEL AND VBA
Additionally, TRAINING
users RESOURCES
can normally VBA
make entries CODE GENERATOR
different from those
Join tens of thousands
within the list. In other words, you can think of a ComboBox as a combination of a TextBox and a
ListBox.LOGIN
ACADEMY of Excel Power Users
Get updates and resources to help you be
more efficient and work faster with Excel.
Additionally, (almost) every week I send one
of the following two emails:
4. CheckBox: Displays a checkbox. Allows users to specify a binary choice: True or False. If the checkbox
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
is checked, its value OK
is button,
True.(ii)Ifclosing/dismissing
the checkbox isn'torchecked,
this notice (iii) continuingits value isthis
to use/browse False.
website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 19/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
5. OptionButton: Usually used in groups. When you have a set of OptionButtons, users can generally
Unsubscribe anytime | 100% privacy | Read our Privacy Policy
select only 1. When a user selects 1 option, Excel automatically de-selects the other options. This
ensures that users only select a single option from the Enter
group. your email here...
You can use Frames (describe in Group #1 above) to separate OptionButtons. OptionButtons within a
Frame are treated as a single group, separate from other groups of OptionButtons. This allows you to
use several sets of OptionButtons, where the user can select an option in each group. Alternatively,
you can work with the OptionButton.GroupName property.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
can select 1 option from within the group. If you don't explicitly group OptionButtons using 1 of the
OK
methods I describe above, Excel treats all the OptionButtons in the UserForm as the same group.
https://powerspreadsheets.com/create-excel-userforms/ 20/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
. ScrollBar: Displays a scrollbar. Users can drag the scrollbar to specify a value.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 21/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
9. SpinButton: Displays a spinner. Allows users to modify a value by clicking on 1 out of 2 arrow buttons.
Unsubscribe anytime | 100% privacy | Read our Privacy Policy
Enter
You can have SpinButtons with either vertical or horizontal your email
orientation. here...
If the spinner is vertically-
oriented, the up arrow increases the value and the down arrow decreases it. If the spinner is
horizontal, the right arrow increases and the down arrowBECOME
decreasesAN
the EXCEL
value. POWER USER
10. RefEdit: Displays a reference edit control, which is a cell range input eld. Users can use this control to
enter or select a cell or range of cells.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 22/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
You're, strictly speaking, not limited to using the built-in controls within
• A VBA codethesnippet/example.
Toolbox or Excel. This is because
you can customize the Toolbox and use other ActiveX controls. However, in this UserForms Tutorial, I
introduce only the controls that appear within the Toolbox. Those are the most commonly-used.
Unsubscribe anytime | 100% privacy | Read our Privacy Policy
Select several controls by either (i) pressing and holding the Ctrl key while you select controls with the
mouse, (ii) pressing and holding the Shift key while you select controls with the mouse, or (iii) clicking-
and-dragging your mouse to enclose the group of controls you want to select.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 23/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
Move a control by dragging-and-dropping it with your mouse. Join tens of thousands
ACADEMY LOGIN of Excel Power Users
Get updates and resources to help you be
more efficient and work faster with Excel.
Additionally, (almost) every week I send one
of the following two emails:
BECOME
Resize a control by selecting and dragging the sizing handles on theAN EXCEL
control's POWER USER
border.
The UserForm itself also has sizing handles, which you can use to resize the UserForm.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 24/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
The purpose of such grid is to help you align all the controls within the UserForm. Depending on your
settings, the controls you work with snap automatically to the grid.
The grid is, in any case, not visible in the actual UserForm displayed to the users.
https://powerspreadsheets.com/create-excel-userforms/ 25/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 26/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
Enter
The settings that apply to the grid are grouped under Form Grid your email
Settings. Within here...
this group of settings, you
nd the following:
BECOME AN EXCEL POWER USER
1. Show Grid: Allows you to specify whether the grid is shown (or not shown). You can set this by
checking (or unchecking) the box to the left of “Show Grid”.
If the checkbox is selected, the grid is displayed. If the checkbox isn't selected, the grid isn't displayed.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 27/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
3. Align Controls to Grid: Allows you to specify whether controls align or snap to the grid. If you want the
controls to snap to grid, select the checkbox next to the left of “Align Controls to Grid”. If the checkbox
isn't selected, controls don't align to the grid.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 28/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
BECOME
Once you've selected the settings you want to use, click the OK button to AN
con EXCEL
rm yourPOWER
selections.USER
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
https://powerspreadsheets.com/create-excel-userforms/ 29/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
You can use the commands in the Format menu or the UserForm toolbar to arrange the controls within a
START LEARNING EXCEL VBA
UserForm. EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
2. Go to the Format menu and select the command you want anytime
Unsubscribe to apply.
| 100% privacy | Read our Privacy Policy
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 30/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 31/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
2. Select the command you want to apply from the context menu.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 32/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
The available commands may vary slightly, depending on the context you're in and which of the 3 methods
Enter your email here...
above you use to access them.
BECOME AN EXCEL POWER USER
The order in which you select the controls matters:
When resizing or moving controls, the VBE must use 1 of them as a reference. You can identify which
controls are moved or resized, and which control is used as reference, based on the color of their sizing
handles. Controls that are resized or moved have black sizing handles. The control that is used as
reference has white sizing handles.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 33/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
The reference control is usually the last one you click on prior to executing the command. This allows you
START LEARNING
to choose EXCEL
the reference VBA after you've
control EXCEL selected
AND VBA all
TRAINING RESOURCES
the controls VBA CODE GENERATOR
you want to manipulate.
Join tens of thousands
Commands In The Format Menu Or UserForm Toolbar
ACADEMY LOGIN of Excel Power Users
The following are the 11 options displayed by the VBE whenGet
youupdates
expand and
the Format menu.
resources Several
to help you of
bethese
commands are also available through the UserForm toolbarmore
or a context
efficient menu, as I faster
and work explain above.
with Excel.
Additionally, (almost) every week I send one
1. Align: Use this to align several controls. You can choose anyfollowing
of the of the following alignment options:
two emails:
Lefts: Aligns the selected controls to the left border of the reference control.
Rights: Aligns the selected controls to the right border of the reference control.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 34/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
Tops: Aligns the selected controls to the top border of the reference control.
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
2. Make Same Size: Allows you to resize the selected controls so that they have the same dimensions.
• A worksheet formula template/example; and
You can choose from within the following resizing options:
• A VBA code snippet/example.
Width: Resizes the selected controls to be of the same width as the reference control. The
height of the controls doesn't change.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
Height: Resizes the selected controls to be of the same height as the reference control. The
width of the controls isn't changed. OK
https://powerspreadsheets.com/create-excel-userforms/ 35/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
4. Size to Grid: Resizes the selected control(s) to the nearest grid points.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 36/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 37/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
Make Equal: Makes the vertical spaces between the selected controls equal.
OK
https://powerspreadsheets.com/create-excel-userforms/ 38/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
Horizontally.
Vertically.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 39/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
. Arrange Buttons: You can use these settings to arrange CommandButtons either of the following
START LEARNING EXCEL VBA
ways: EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
Right: Arranges the selected CommandButton(s) on the right side of the UserForm.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 40/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
11. Order: Allows you to order a stack of controls from the front to the back. You can choose any of the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
following commands:
OK
https://powerspreadsheets.com/create-excel-userforms/ 41/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
Bring to Front: Brings the selected control to the front of the stack.
Send to Back: Sends the selected control to the back of the stack.
The UserForm toolbar contains several of the commands I list above. Additionally, it contains a Zoom drop-
down list. This zoom feature allows you to zoom into or out of the UserForm controls. In other words,
controls are resized per the percentage you choose.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 42/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
How To Customize A UserForm Or Its Controls Unsubscribe anytime | 100% privacy | Read our Privacy Policy
You usually rely on this option if you want to set properties at runtime. This means that you can use
VBA to set properties when the UserForm is displayed.
This applies only to some properties, particularly those related to size and position such as Height,
Width, Left and Top. You can learn more about this topic by reading the previous section.
This is the option you generally use while designing your UserForm within the VBE and is the focus of
this section. The properties you set through the Properties Window are usually static (vs. dynamic)
and, therefore, you rarely use VBA code (#1 above) to modify them later.
While designing a UserForm within the VBE, you can change a property through the Properties Window in
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
the following 3 easy steps:
OK
https://powerspreadsheets.com/create-excel-userforms/ 43/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
1. Within the UserForm window, select (i) the control you want to customize, or (ii) the UserForm itself.
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
2. Go to the Properties Window and select the property you want to modify.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 44/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
3. Set the new property value. Unsubscribe anytime | 100% privacy | Read our Privacy Policy
In this UserForms Tutorial, I focus on the basics of creating and designing UserForms. Therefore, I only
explain how to use the Properties Window of the VBE for these purposes. In the UserForm example that
appears in the second section of this blog post, you can nd some basic examples of how to use VBA to set
the properties of a UserForm or its controls programmatically.
The UserForm object and the controls within the UserForm itself are also objects and, therefore, also have
properties. The basic purpose of these properties doesn't change: they allow you to describe the attributes,
characteristics or qualities of an object.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
There's, however, an important difference between the way you usually work with properties (i) within VBA,
OK
and (ii) when dealing with UserForms and UserForm controls.
https://powerspreadsheets.com/create-excel-userforms/ 45/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
When you create macros, you usually use VBA code to either return (read) or modify (write) the current
STARTsetting.
property LEARNING EXCEL
When youVBA
work withEXCEL AND VBA
UserForms, youTRAINING
can also RESOURCES
use VBA. However,VBA
youCODE GENERATOR
can also modify
UserForm and UserForm control properties in a different way: Join tens of thousands
ACADEMY LOGIN
By using…
of Excel Power Users
Get updates and resources to help you be
The Properties Window more efficient and work faster with Excel.
Additionally, (almost) every week I send one
ofleft
The Properties Window is commonly displayed on the lower thecorner
following twoVBE,
of the emails:
although this varies. You
can get the VBE to show the Properties Window by, for example, using the “F4” keyboard shortcut.
• A worksheet formula template/example; and
The Properties Window shows the properties of the currently-selected object. If your current selection
includes more than 1 object, the Properties Window lists the properties that are common to the selected
objects.
Alternatively, you can use the drop-down list at the top of the Properties Window to specify the object
whose properties you want to see.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 46/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
Regardless
This website usesof the (both
cookies categorization criteria
ours and from Third you
Parties) for use, the
the purposes properties
set forth in our Privacydon't
Policy. change. The
You accept the Properties
use of Window
these cookies by liststhe
either (i) clicking
an object's properties andOK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
those properties don't change just because they're listed in a different order.
OK
https://powerspreadsheets.com/create-excel-userforms/ 47/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
2. Double-click the right column of the Properties Window and enter the new property setting.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
https://powerspreadsheets.com/create-excel-userforms/ 48/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START1.LEARNING
By typingEXCEL VBAsetting.EXCEL AND VBA TRAINING RESOURCES
the new VBA CODE GENERATOR
When working with these properties you can either (i) click on the drop-down and select a value,
or (ii) double-click the property name or property value to cycle through the available values.
3. By opening a dialog box. You can identify the properties whose setting you specify through a
dialog box because, when selected, the VBE displays a button with an ellipsis (…).
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 49/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
You can modify the properties of several objects at the same time. To do this, select all the objects whose
STARTyou
property LEARNING
want toEXCEL VBA
modify EXCEL AND
prior to executing VBA
the TRAINING
2-step RESOURCES
process VBA
I describe above. CODE
When GENERATOR
you select several
objects at the same time, the Properties Window displays those properties that are common to the Join tens of thousands
selection.
ACADEMY LOGIN of Excel Power Users
Get updates and resources to help you be
more efficient and work faster with Excel.
Additionally, (almost) every week I send one
of the following two emails:
Some of the properties of the UserForm are default settings for new controls. In other words, the new
controls you add to the UserForm are in uenced by that property setting. Therefore, if you modify those
default control settings:
Controls added after the property modi cation use the new property setting, but…
Controls added prior to the property modi cation remain unchanged and don't use the new property
setting.
https://powerspreadsheets.com/create-excel-userforms/ 50/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
In practice, you usually modify just a few properties through the Properties Window. Name is 1 such
STARTthat
property LEARNING EXCELset
you usually VBAthrough EXCEL AND VBAWindow.
the Properties TRAINING RESOURCES VBA CODE GENERATOR
This may look familiar. Excel uses similar naming conventions for workbooks,
• A VBA worksheets, and regular VBA
code snippet/example.
modules (among others).
You use the Name property of a UserForm or a UserForm control to refer to it when creating your VBA
code. Since you may use these names relatively often, you may prefer using names that are more
descriptive and meaningful than the default ones.
Notice, additionally, that any time you change the Name property of a UserForm or a UserForm control, you
may have to go back to your VBA code to update the object references. To avoid this, you may prefer
modifying the names of your UserForms and UserForm controls as soon as possible after creating them
and prior to writing your VBA code.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
The maximum name length is 40 characters.
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
The rst character must be a letter.
OK numbers and underscores (_).
Characters, other than the rst, can include letters,
https://powerspreadsheets.com/create-excel-userforms/ 51/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
Names can't include spaces ( ), periods (.), mathematical operators (such as +, -, /, * or ^), comparison
START LEARNING
operators EXCEL VBA
(for example, EXCEL
>, < or =), AND VBA
or certain TRAININGcharacters
punctuation RESOURCES (such asVBA
@, #,CODE
$, %,GENERATOR
&, and !).
Join tens of thousands
Names must be unique within the object's scope. Notice that the scope of a UserForm is different
from the
ACADEMY scope of a UserForm control.
LOGIN of Excel Power Users
The scope of a UserForm is, generally, the whole VBA Project. Therefore, UserForm names must
be unique within the workbook. Get updates and resources to help you be
more efficient and work faster with Excel.
The scope of a UserForm control is, generally, the UserForm where its located. Therefore,
Additionally, (almost) every week I send one
UserForm control names must be unique within the UserForm.
of the following two emails:
A common naming convention for UserForms and UserForm controls involves adding a control identi er
• A worksheet formula template/example; and
at the beginning of the name. You do this by adding a 3-letter pre x to the control name. The following table
lists some commonly used pre xes described in, among others, Excel
• A VBA 2016
code Power Programming with VBA
snippet/example.
and Mastering VBA for Microsoft O ce 2016.
CommandButton cmd
Frame fra
Image img
Label lbl
MultiPage mpg
OptionButton opt
RefEdit ref
ScrollBar scr
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
SpinButton spb
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
TabStrip tab or tbs
https://powerspreadsheets.com/create-excel-userforms/ 52/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
TextBox
START LEARNING EXCEL VBA txt or tbx VBA CODE GENERATOR
EXCEL AND VBA TRAINING RESOURCES
You can easily delete controls from a UserForm using either of the following 2 methods:
• A worksheet formula template/example; and
1. Select the control and go to Edit > Delete, or press the Delete key.
• A VBA code snippet/example.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 53/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
2. Right-click on the control and select Delete from the context menu.
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
1. Go to the Code window of the UserForm by, for example, using the “F7” keyboard shortcut.
2. Enter the appropriate VBA code within this Code window.
This section focuses on the macros that you attach or assign to the UserForm. This is different from the
macros responsible for displaying the UserForm in the rst place.
In other words, when working with UserForms, you deal with (at least) 2 different types of Sub procedures:
1. A Sub procedure that displays the UserForm. You can read more about this topic in a section further
below.
2. 1 or more event-handler procedures, which are attached to the UserForm. This is the topic of this
section.
Additional considerations apply to the VBA code you use to close the UserForm, even though this code is
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
commonly attached to theOKUserForm. I explain how you can close or hide a UserForm further below.
button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
https://powerspreadsheets.com/create-excel-userforms/ 54/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
When working with UserForms, you create event-handler procedures that are stored within the code
STARTofLEARNING
module EXCEL VBA
the appropriate UserForm EXCEL
object.AND VBA words:
In other TRAINING RESOURCES VBA CODE GENERATOR
Get updates
You use this module to store the procedures to be executed when aand resources
user to help
works with you be
the UserForm.
more efficient and work faster with Excel.
The procedures you assign to UserForms are event-handler procedures. In other words, these
Additionally, (almost) every week I send one
procedures are executed when an event occurs. In the case of UserForms, these events are the
of the following two emails:
consequence of the user interacting with the UserForm.
1. The UserForm window: You use this module to manipulate and customize the UserForm and its
controls.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 55/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
2. The Code window: You use this module to create and store the event-handler procedures associated
with the UserForm.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 56/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
You can toggle back and forth between these 2 windows with any of the 3 following features:
OK
https://powerspreadsheets.com/create-excel-userforms/ 57/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
2. The View Code and View Object commands within the View menu.
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
Go to View > Code to see the Code window. Join tens of thousands
ACADEMY LOGIN of Excel Power Users
Get updates and resources to help you be
more efficient and work faster with Excel.
Additionally, (almost) every week I send one
of the following two emails:
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 58/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
3. The context menu displayed when you right-click on the UserForm within the Project Explorer.
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
If you want to go to the UserForm window, you can generally double-click the UserForm within the Project
Explorer.
From a broad perspective, an event is something that happens while you're working with Excel. In the case
START LEARNING
of UserForms, theseEXCEL VBA that occur
are events EXCELwithin
AND VBA TRAINING RESOURCES
the UserForm VBA CODEevent
itself. Once the appropriate GENERATOR
occurs,
Join tens of thousands
your event-handler procedure is executed. This way, your VBA application can respond to the user's actions.
ACADEMY LOGIN of Excel Power Users
When working with UserForms, your code must respond to both UserForm and control events. The events
Get
you can work with vary depending on the UserForm control. In updates and UserForm
other words, resources controls
to help you be
have
different associated events. more efficient and work faster with Excel.
Additionally, (almost) every week I send one
of the following two emails:
How To Create Event-Handler Procedures For UserForms
• A aworksheet
The general principles that apply to event-handler procedures, formula
topic I cover in thistemplate/example;
blog post, are and
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 60/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
2. Click on the Object drop-down list that appears at the top left side of the UserForm Code window. This
drop-down is labeled “(General)”.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 61/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
When you expand this drop-down list, the VBE displays the UserForm and all the UserForm controls
within the relevant UserForm.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 62/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 63/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
4. Once you select an object, the VBE includes the declaration and End statements for a Sub procedure.
This Sub procedure corresponds to the default event of the object you chose.
In the screenshot below, the VBE enters the opening and closing statements for the Sub procedure
triggered by the Click event of the UserForm object (Private Sub UserForm_Click()).
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 64/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
5. If you want to work with the default event of the chosen object, you can start working on your Sub
procedure. Use the statements entered by the VBE in step #4 above as a basis.
https://powerspreadsheets.com/create-excel-userforms/ 65/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
The expanded drop-down list includes all the events that apply to the object you're working with.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 66/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 67/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
. Once you select an event, the VBE enters new declaration and End statements for a Sub procedure.
This Sub procedure corresponds to your chosen object and event.
OK
https://powerspreadsheets.com/create-excel-userforms/ 68/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
9. Notice that the VBE doesn't delete the declaration and End statements for the Sub procedure that
works with the default event (step #4). If you want to keep a clean module, you can delete them.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 69/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
If you're working in the UserForm window, you can use an alternative process. In this case, you can get the
VBE to enter the declaration statement for the event-handler procedure in the following 2 simple steps:
1. Either (i) double-click on the object you want to work with, or (ii) right-click on the object and select
“View Code”.
OK
https://powerspreadsheets.com/create-excel-userforms/ 70/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
For example, in the screenshot below, the VBE adds the opening and closing statements for a macro
triggered by the Click event of the CommandButton (Private Sub CommandButton1_Click())
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 71/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
If you want to work with the default event of the object, you can start coding your Sub procedure.
If you want to work with another event, repeat steps #6 through #9 from the process I describe above,
as follows:
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
1. Click on the Procedure drop-down list.
OK
https://powerspreadsheets.com/create-excel-userforms/ 72/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 73/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
3. Start coding your Sub procedure, using the declaration and End statements that the VBE enters
as a basis.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 74/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
4. If necessary, delete the declaration and End statements for the default event.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 75/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 76/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
You can see how to, and why, modify the Name property of UserForm controls in a previous section.
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
“ Control
Enter your email here...
“ Me.Control
2. Within the appropriate procedure, enter a statement that uses the Show method of the UserForm
object. The basic structure of this statement is as follows:
“ UserForm.Show
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
“UserForm” is an optional UserForm object. If you omit this quali er, VBA assumes you're referring to
the UserForm that is associated with the activeOK
UserForm module.
https://powerspreadsheets.com/create-excel-userforms/ 77/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START
TheLEARNING EXCEL
Show method VBA
has EXCEL
1 parameter: AND VBA
modal. ThisTRAINING RESOURCES
allows you VBAthe
to specify whether CODE GENERATOR
UserForm is modal
Join tens of thousands
or modeless. I don't cover this topic in this UserForms Tutorial.
ACADEMY LOGIN of Excel Power Users
When choosing the procedure in which to include the Show method, consider how and when you want the
user to access the UserForm. You can, for example: Get updates and resources to help you be
more efficient and work faster with Excel.
Additionally, (almost) every week I send one
1. Create a procedure whose sole purpose is to display the UserForm.
of the following two emails:
2. Assign that procedure to a button or keyboard shortcut.
You can load a UserForm, without displaying it, by working with the Load statement. In this case, the basic
Unsubscribe anytime | 100% privacy | Read our Privacy Policy
statement syntax is as follows:
Enter your email here...
When a UserForm is loaded, it exists in memory but isn't visible. Therefore, you can programmatically work
with the UserForm. The user, however, can't interact with it.
Once you want to display a previously-loaded UserForm, you can use the Show method of the UserForm
object.
You usually load a UserForm, without displaying it immediately, when the UserForm is complex and takes
too long to load into memory. Once the UserForm is loaded in memory, you can quickly display it.
In certain cases, VBA loads the UserForm automatically without you having to use the Load statement.
This is the case when you use the Show method of the UserForm object (above).
https://powerspreadsheets.com/create-excel-userforms/ 78/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
To understand why this is the case, it may help if you consider the following 3 separate steps:
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
1. First, you need to get Excel to display the UserForm. Join tens of thousands
2. Once the
ACADEMY UserForm is shown, the user can work with it.
LOGIN of Excel Power Users
3. Depending on what the user does with the UserForm, something happens.
Get updates and resources to help you be
The code that determines what happens depending on howmore efficient
the user and work
interacts faster
with the with Excel.
UserForm (step #3)
Additionally, (almost) every week I send one
is stored within the UserForm. If the UserForm is never displayed, the user doesn't interact with the
of the following two emails:
UserForm and this code is never executed.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 79/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
When you execute the Run Sub/UserForm command, the Initialize event of the UserForm occurs. This
option is useful for testing or preparing a UserForm you're working on.
As an alternative to the Run Sub/UserForm command, you can use the Show method of the UserForm
object in a statement typed in the Immediate Window. The basic structure of such a statement is:
“ UserForm.Show
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 80/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
OK
https://powerspreadsheets.com/create-excel-userforms/ 81/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
. Once the UserForm is closed, Excel continues execution of the procedure that contains the Show
• A worksheet formula template/example; and
method of the UserForm object. This is the Sub procedure responsible for displaying the UserForm
(step #1 above). • A VBA code snippet/example.
In practice, however, the VBA statement that displays the UserForm is at (or near) the end of a
Unsubscribe anytime | 100% privacy | Read our Privacy Policy
procedure. This is because you usually store the code that is executed after the user works with the
Enter
UserForm in the UserForm Code module. The code within theyour emailCode
UserForm here...
module is executed in
earlier steps of this process (steps #2 to #4 above).
BECOME AN EXCEL POWER USER
You can read more about the UserForm Code module in a previous section of this UserForm Tutorial.
The rst way in which a UserForm can be closed is by clicking on its Close button on the top right corner.
This generally applies to all UserForms, regardless of the VBA code you use.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 82/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
You can, however, monitor whether a user clicks on the Close button by using events. Clicking on the Close
button triggers the following 2 events: Unsubscribe anytime | 100% privacy | Read our Privacy Policy
Usually, when you're creating a UserForm, you create an event-handler procedure that is triggered by the
Click event of a CommandButton. This event-handler procedure normally includes 1 of the following VBA
constructs:
1. The Unload statement, which unloads the UserForm from memory. The basic statement structure for
the Unload statement is as follows:
“ Unload UserForm
2. The UserForm.Hide method, which makes the UserForm invisible. The basic statement syntax for the
UserForm.Hide method is as follows:
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
“ UserForm.HideOK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 83/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
This topic is important because, once a UserForm is unloaded, the changes made to the UserForm's
controls and their properties are reset. This results, as explained in Excel 2016 Power Programming with
VBA, your code not being “able to access the user's choices after the UserForm is unloaded.”
There may be cases where you need to use the input from a UserForm after the UserForm is unloaded.
You can usually store that data using a public-scope variable. Other possible solutions suggested by VBA
experts Dick Kusleika and Mike Alexander in Excel 2016 Power Programming with VBA include writing the
value to a worksheet cell or the Windows registry.
The UserForm.Hide method doesn't unload the UserForm from memory. It simply hides the UserForm.
Therefore, you can still access and work with the user's choices and the UserForm controls.
In fact, if you use the UserForm.Hide method on an unloaded UserForm, VBA loads the UserForm and
keeps it hidden.
OK
https://powerspreadsheets.com/create-excel-userforms/ 84/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
“START
The method you choose depends on why you don't want the UserForm to be seen. Most of the
LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
time, you'll want the form cleared from memory, but sometimes, information that was entered
Join tens of thousands
into the form needs to be referred to the next time you show the form while the workbook has
remained
ACADEMY open.
LOGIN of Excel Power Users
Get updates and resources to help you be
Example: Create A Simple UserForm For Data Entry
Additionally, (almost) every week I send one
more efficient and work faster with Excel.
The purpose of the example UserForm is to serve as a data entry mechanism for a workbook table
recording certain sales data. The entries are as follows:
Item.
Units Sold.
The worksheet where these entries are recorded has 2 single columns. These columns match with the
entries above.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 85/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
• AI use
These entries are the part of the basis for several tables that VBAincode
othersnippet/example.
Tutorials, such as this one about
Pivot Tables or this one about Power Query.
Unsubscribe anytime | 100% privacy | Read our Privacy Policy
The example UserForm that you create below works with the following UserForm controls:
Enter your email here...
1 Label.
BECOME AN EXCEL POWER USER
1 TextBox.
1 SpinButton.
1 Frame.
5 OptionButtons.
2 CommandButtons.
In the following sections, you follow the 6-step process described at the beginning of this Tutorial to create
a UserForm:
1. Insert a UserForm.
2. Add controls to the UserForm.
3. Move or resize the UserForm controls.
4. Customize the UserForm or its controls.
5. Assign VBA code to the UserForm.
. Display or load the UserForm.
7. Close or hide the UserForm.
The purpose
This website of this
uses cookies section
(both is to
ours and from show
Third Parties)you,
for thestep-by-step,
purposes set forth inthe practical
our Privacy process
Policy. You accept theyou
use ofcan
thesefollow
cookies byto create
either a the
(i) clicking
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
UserForm. The logic and theory behind each of these steps is thoroughly described in the appropriate
OKinformation and details.
section above. Please refer to those sections for more
https://powerspreadsheets.com/create-excel-userforms/ 86/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
The UserForm example you create is very simple. My purpose with this blog post is to get you started
STARTUserForms.
creating LEARNING EXCEL VBA I don'tEXCEL
Therefore, ANDcertain
dive into VBA TRAINING
features RESOURCES
or VBA constructsVBA
thatCODE GENERATOR
you can use and add
to improve the UserForm and make it more sophisticated or complex. Join tens of thousands
ACADEMY LOGIN of Excel Power Users
Step #1: Insert A UserForm
Get updates and resources to help you be
Insert the UserForm by following these 3 easy steps: more efficient and work faster with Excel.
Additionally, (almost) every week I send one
of the following two emails:
1. Use the “Alt + F11” keyboard shortcut to go to the VBE.
• A(workbook)
2. Go to the Project Explorer and right-click on the Project worksheet you're
formula template/example;
working and
on. In this example,
select “VBAProject(Create Excel UserForms For Data Entry In 6 Easy Steps.xlsm)”.
• A VBA code snippet/example.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
https://powerspreadsheets.com/create-excel-userforms/ 87/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
1. Item.
2. Units Sold.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
To achieve this, use the following controls for the UserForm:
https://powerspreadsheets.com/create-excel-userforms/ 88/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
In the case of the CommandButtons and OptionButtons, use the following 3-step process:
Unsubscribe anytime | 100% privacy | Read our Privacy Policy
1. Double-click on the control within the Toolbox. Enter your email here...
2. Click on the UserForm several times, once for each time you add the control (2 for the
CommandButtons, 5 for the OptionButtons). BECOME AN EXCEL POWER USER
3. Click on the Select Objects command in the Toolbox to restore the mouse pointer to Selection mode.
Due to the amount of controls you include in the UserForm, start by resizing the UserForm itself. Your
purpose is to make the UserForm taller. You do this by clicking and dragging on the UserForm's lower center
sizing handle.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 89/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
Once the UserForm is big enough to t all the controls you want to add, and due to the layout choice, add
theSTART LEARNING
controls EXCEL VBA
in the following order: EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
In this step, don't worry too much in getting the precise location right. You organize the controls with more
detail in the next step.
https://powerspreadsheets.com/create-excel-userforms/ 90/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
https://powerspreadsheets.com/create-excel-userforms/ 91/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
Customize the following 2 properties of all UserForm and UserForm controls that contain them:
Enter your email here...
1. Name: The name of the UserForm or control.
BECOME AN EXCEL POWER USER
2. Caption: Caption text that is displayed (i) within or next to a control, or (ii) in the UserForm title bar.
The only exceptions are the TextBox and SpinButton. The TextBox and SpinButton objects don't have a
Caption property.
In addition to the above, make the following speci c property modi cations:
1. Set the Default property of the Record Entry button to True. The Default property allows you to specify
whether a CommandButton is the default button in the UserForm.
2. Set the Cancel property of the Close Form button to True. You can use the Cancel property to specify
that a CommandButton is the Cancel button. If you do this, the user can use the Escape key as a
shortcut for the Close Form button.
3. Set the Enabled property of the TextBox to False. You can use the Enabled property to indicate
whether the TextBox is enabled and respond to the user's actions (True) or disabled (False).
4. Set the Locked property of the TextBox to True. The Locked property allows you to specify if the
user can edit the entry or data within the TextBox. By locking the TextBox, you ensure that the user
can't edit, add or delete data in the TextBox.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
Follow the same 3-step process for all objects whose properties are modi ed:
OK
https://powerspreadsheets.com/create-excel-userforms/ 92/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
Strictly speaking, you don't need to specify the Name property of all the objects above. This is because you
don't refer to most of them (for example, the Label and Frame) within the VBA code you create in the
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
following steps. However, OK
asbutton,
I explain above, you
(ii) closing/dismissing thisgenerally want to
notice or (iii) continuing use meaningful
to use/browse this website. and descriptive names
https://powerspreadsheets.com/create-excel-userforms/ 93/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
The following GIF shows the whole process to change the properties above:
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
1. A macro that prepares the UserForm for use by setting the default states of the TextBox, SpinButton
and OptionButtons in the UserForm.
2. A macro that records entries.
3. A macro that connects the TextBox to the SpinButton, so that changes to the SpinButton are re ected
in the TextBox.
I explain the VBA code used to display and close the UserForm in the following steps (#6 and #7).
The 8-step process you can follow to enter the VBA code for the UserForm is as follows:
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 94/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 95/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 96/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
4. Enter the VBA code for the Sub procedure triggered when the user clicks on the arrows of
spinButtonUnits.
5. Click on the Object drop-down list, and select the UserForm object (UserForm).
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 97/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
Because of this, the VBE enters the declaration and End statements for a Sub procedure triggered by
the Click event of the UserForm.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 98/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 99/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
The VBE enters the opening and closing statements of a Sub procedure triggered by the Initialize
event of the UserForm (Private Sub UserForm_Initialize()). The Initialize event happens when the
UserForm is loaded, but prior to it being displayed. Therefore, you usually rely on Initialize to specify
default values or ll controls with data.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 100/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
7. Delete the opening and closing statements entered by the VBE in step #5 above (Private Sub
Enter your email here...
UserForm_Click()).
. Enter the VBE code for the macro triggered when the UserForm is initialized.
Let's look at the VBA code for the 3 procedures you create in this step:
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
https://powerspreadsheets.com/create-excel-userforms/ 101/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
The following is the VBA code for the macro executed when the UserForm is initialized:
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
Value of TextBox: 0.
Value of SpinButton: 0.
Selected OptionButton: Surface Studio.
You can also manipulate these properties through the Properties Window (step #4 above).
One of the main reasons I prefer to set these default property values through VBA code is that this allows
me to reuse the code within this Sub procedure to reset the UserForm and prepare it for a new entry. In fact,
the last statement in Sub procedure #2 below calls the UserForm_Initialize macro for these purposes.
The statements within theOKblock (lines #2 to #4) work with the object speci ed in the opening line of the
button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
block (Me). You use the Me keyword to refer to the UserForm itself.
OK
https://powerspreadsheets.com/create-excel-userforms/ 102/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
You do this by setting the Value property of the SpinButton to 0. The Value property of a SpinButton is an
• A VBA code snippet/example.
integer.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 103/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
1. Find the rst empty row in the worksheet where the entered data is recorded.
2. Record the user entries in that rst empty row, as follows:
1. The Item chosen with the OptionButtons of the UserForm is recorded in column A.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
2. The number ofOKunits
button,displayed in thethisTextBox
(ii) closing/dismissing notice or (iii)of the UserForm
continuing is recorded
to use/browse this website. in column B.
3. Prepare the UserForm for a new entry by:
1. Resetting the values of the TextBox and SpinButton.
OK
https://powerspreadsheets.com/create-excel-userforms/ 104/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
BECOME
This Sub procedure doesn't close the UserForm. Therefore, the AN EXCEL
user can make severalPOWER
entries at USER
any time
without having to continually open the dialog box. The user can, however, close the dialog box at any time
by clicking on the Close or Close Form buttons. See step #7 below to see how to close the dialog box with
the Close Form button.
Let's go through each line of code to understand how the macro works:
1. myWorksheet: An object variable. Represents the worksheet where the data is recorded.
2. myFirstBlankRow: A variable of the Long data type. Represents the number of the rst blank row in
the table where the data is recorded.
https://powerspreadsheets.com/create-excel-userforms/ 105/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
Opening and closing statements of a With… End With block. The statements within the block (lines #5 to
START
#20) workLEARNING EXCELspeci
with the object VBA ed inEXCEL AND VBA
the opening lineTRAINING RESOURCES
of the block (myWorksheet).VBA CODE GENERATOR
Join tens of thousands
Lines #5: myFirstBlankRow = .Cells.Find(What:=”*”, LookIn:=xlFormulas, LookAt:=xlPart,
ACADEMY LOGIN of Excel
SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row + 1 Power Users
Get updates and resources to help you be
Finds the rst empty row in myWorksheet and assigns its number to the myFirstBlankRow variable.
more efficient and work faster with Excel.
Additionally, (almost) every week I send one
The process followed to nd the rst empty row in the worksheet is as follows:
of the following two emails:
Let's analyze the portion of the statement that nds the last row in the worksheet. I explain several different
ways to nd the last row in a worksheet in this VBA Tutorial.Enter your email here...
Once the last row in the worksheet is identi ed, 1 is added (+ 1). The resulting value is assigned to the
myFirstBlankRow variable (myFirstBlankRow =).
Lines #6usesAnd
This website #19:
cookies With
(both ours .Cells(myFirstBlankRow,
and from 1)Privacy
Third Parties) for the purposes set forth in our | End With
Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
Opening and closing statements of a With… End With block. The statements within the block (lines #7 to
OKof the block (.Cells(myFirstBlankRow, 1)).
#18) work with the object speci ed in the opening line
https://powerspreadsheets.com/create-excel-userforms/ 106/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
Executes one of the groups of statements within this block of code (lines #8 to #17) based on the value
taken by an expression. The group of statements that's executed is determined by nding which expression
matches the test expression.
The test expression is set in the opening line of code (#7) of the block. In this case, a Boolean value: True
(Select Case True).
https://powerspreadsheets.com/create-excel-userforms/ 107/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
The following table shows the tested expressions along with the statement that's executed when that
START LEARNING
expression EXCEL VBA
returns True: EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
Overall, the consequence of the above structure is that the data recorded in the Excel worksheet depends
on the OptionButton the user chooses, as follows:
IfThis
thewebsite
useruses
chooses The
cookies (both ours and from Third Parties) for the purposes set forth in our data
Privacy entry
Policy. is the use of these cookies by either (i) clicking the
You accept
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
https://powerspreadsheets.com/create-excel-userforms/ 108/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
Xboxof
OneExcel Power Users
ACADEMY LOGIN
Xbox One S S
Get updates and resources to help you be
Xbox One Xbox One
more efficient and work faster with Excel.
Additionally, (almost) every week I send one
of the following two emails:
Line #20: .Cells(myFirstBlankRow, 2).Value = Me.textBoxUnits.Value
• A worksheet
Records the number of units within the No. of units sold TextBox formula template/example;
in the appropriate worksheet cell. and
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
Line #22: UserForm_Initialize
OK
https://powerspreadsheets.com/create-excel-userforms/ 109/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
Calls the UserForm_Initialize Sub procedure. I explain this event-handler procedure in more detail above
START
(Sub LEARNING
procedure #1). EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
The following is the VBA code within the Sub procedure executed when the user clicks on any of the arrows
Enter your email here...
of the SpinButton control:
https://powerspreadsheets.com/create-excel-userforms/ 110/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
This statement sets the Value property of the TextBox object (textBoxUnits.Value) to be equal to the Value
STARTof
property LEARNING EXCEL VBA
the SpinButton EXCEL AND VBA TRAININGInRESOURCES
object (Me.spinButtonUnits.Value). other words, it: VBA CODE GENERATOR
Join tens of thousands
Connects
ACADEMY the TextBox to the SpinButton.
LOGIN of Excel Power Users
Ensures that the value displayed in the TextBox is determined by the SpinButton.
Get updates and resources to help you be
Step #6: Display The UserForm more efficient and work faster with Excel.
Additionally, (almost) every week I send one
of the following
For this example, get Excel to display the UserForm in the following two
3 simple emails:
steps:
If necessary, insert a new module by, for example, right-clicking on the workbook within the Project Explorer
and going to Insert > Module.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 111/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
Step #2: Create A Sub Procedure That Calls The Show Method Of The UserForm
Object
Create the following macro (displayUserForm):
“ userFormSalesEntry.Show
OK
https://powerspreadsheets.com/create-excel-userforms/ 112/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
When executed, this macro displays the userFormSalesEntry you created in the previous 5 steps.
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
3. Within the Macro Options dialog box displayed by Excel, assign a keyboard shortcut and click the OK
button.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
https://powerspreadsheets.com/create-excel-userforms/ 113/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
https://powerspreadsheets.com/create-excel-userforms/ 114/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
A user can close the dialog box example by clicking on the Close Form button. You can enter the code to
START
close the LEARNING EXCELthe
UserForm when VBAuser clicks
EXCEL
thisAND VBAinTRAINING
button RESOURCES
the following 4 easy steps: VBA CODE GENERATOR
Join tens of thousands
1. Go to the
ACADEMY of Excel Power Users
VBE by, for example, using the “Alt + F11” keyboard shortcut.
LOGIN
3. Double-click on the button you want to use to close the UserForm (Close Form).
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 115/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 116/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
4. Enter the VBA code for the Sub procedure triggered when the user clicks the Close Form button. In
this example, this procedure includes a statement with the Unload statement.
The following is the code within the Sub procedure executed when the user clicks the Close Form button:
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 117/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
The Unload statement unloads the UserForm from memory. This results in the dialog box being dismissed.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 118/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
3. To make an entry: Join tens of thousands
ACADEMY LOGIN of Excel Power Users
1. Enter the number of units sold by using the SpinButton.
Get updates and resources to help you be
more efficient and work faster with Excel.
2. Choose the appropriate Item.
Additionally, (almost) every week I send one
of the following two emails:
3. Click on the Record Entry button.
4. Repeat step #3 as many times as required, depending on the number of entries you want to make.
https://powerspreadsheets.com/create-excel-userforms/ 119/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
When I click the Close Form button, the dialog box is closed.
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
Conclusion
After reading this UserForms Tutorial, you have the knowledge and resources to start creating UserForms
in Excel now. The following are some of the topics you learned about:
In the second section of this UserForms Tutorial, you saw a practical example. In this example, you
followed the easy 6-step process to create a simple UserForm for data entry. Remember that this blog
post is accompanied
This website uses cookies (both by
ours an Excel
and from Thirdworkbook
Parties) for the example containing
purposes set forth in our Privacythis UserForm
Policy. You accept the example. Youbycan
use of these cookies eitherget
(i) clicking the
OK
https://powerspreadsheets.com/create-excel-userforms/ 120/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 121/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example
START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
3. Excel Resources
Copyright © 2015–2021 PDS Intelligence Pte. Ltd. All rights reserved. | Imprint/Impressum | Privacy Policy | A liate
Disclosure | Terms and Conditions | Limit of Liability and Disclaimer of Warranty | Excel ® is a registered trademark
of the Microsoft Corporation. Power Spreadsheets is not a liated with the Microsoft Corporation.
This website uses cookies (both ours and from Third Parties) for the purposes set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
OK
https://powerspreadsheets.com/create-excel-userforms/ 122/122