Create Excel UserForms For Data Entry in 6 Easy Steps - Tutorial and Practical Example

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 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

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:

• A worksheet formula template/example; and

Create Excel UserForms For Data Entry In 6 • A VBA code snippet/example.

Easy Steps: Tutorial And Practical Example


Unsubscribe anytime | 100% privacy | Read our Privacy Policy
By J.A. Gomez
Enter your email here...
When working in Excel, you have a few ways to get information from a user and allow them to enter data.
These include the following: BECOME AN EXCEL POWER USER

Message boxes.
Input boxes.
The GetOpenFilename method.
The GetSaveAsFilename method.
The FileDialog method.
Excel worksheets.
UserForms.

Out of the features I describe above, UserForms are one of


the most powerful and e cient alternatives. Unless the
information or input you need to get from the user is limited,
UserForms are usually a good solution.

As explained in Mastering VBA for Microsoft O ce 2016:

“ 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

Join tens of thousands


1. First section:
ACADEMY of
LOGIN I introduce (i) UserForms, (ii) the simple 6-step Excel Power Users
process you can use to create Excel
UserForms, and (iii) the main constructs you use when designing and programming UserForms.
Get updates
2. Second section: I walk you through a step-by-step practical exampleandofresources to help
how to create you be
a simple
more efficient and work faster with Excel.
UserForm for data entry. In this section, you can see how the process of creating a UserForm
Additionally, (almost) every week I send one
(described in section #1) looks in practice.
of the following two emails:

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.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER


The following Table of Contents lists the main sections of this Tutorial.

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

How To Toggle Between The Code And UserForm Windows


START LEARNING Work
Why UserForms EXCELWith
VBAEvent-Handler
EXCELProcedures
AND VBA TRAINING RESOURCES VBA CODE GENERATOR
How To Create Event-Handler Procedures For UserForms
How To Refer To UserForm Controls Within Your Code
Join tens of thousands
ACADEMY LOGIN
How To Display Or Load A UserForm of Excel Power Users
Where To Store The Macro That Displays A UserForm
Get updates and resources to help you be
How To Display A UserForm From The VBE
more efficient and work faster with Excel.
How Is The Control Flow When Excel Displays A UserForm
Additionally, (almost) every week I send one
How To Close Or Hide A UserForm
of the following two emails:
Example: Create A Simple UserForm For Data Entry
Step #1: Insert A UserForm
• A worksheet formula template/example; and
Step #2: Add Controls To The UserForm
Step #3: Move Or Resize The UserForm Controls
• A VBA code snippet/example.
Step #4: Customize The UserForm And Its Controls
Step #5: Assign VBA Code To The UserForm
Step #6: Display The UserForm Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Step #7: Close The UserForm


UserForm For Data Entry In Action Enter your email here...
Conclusion
Books Referenced In This UserForms Tutorial BECOME AN EXCEL POWER USER

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.

Why Work With UserForms


OK

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

Join tens of thousands


As ACADEMY
I mention LOGIN
of Excel Power Users
at the beginning of this UserForms Tutorial, there are a few ways in which you can display
information and get input from a user. Some of the non-UserForm alternatives, such as Message and Input
Boxes, work great in relatively simple cases. In fact, in suchGet updates
simple and
cases, resources
Message andtoInput
help Boxes
you beare
more efficient and work faster with Excel.
probably more appropriate than UserForms.
Additionally, (almost) every week I send one
of the following two emails:
There are, however, several circumstances where those alternatives aren't powerful enough for your
purposes. Consider, for example, the following scenarios or considerations:
• A worksheet formula template/example; and

A user should make choices or decisions that can't be• adequately


A VBA codecaptured by the limited controls
snippet/example.
available in Message or Input boxes.
The macro requires the user to make several different data entries.
Unsubscribe anytime | 100% privacy | Read our Privacy Policy
The user input you require is too specialized or complex for Message or Input boxes.
You want to restrict the choices users can make or theEnter your
data they email
can enter here...
by establishing
sophisticated or complex data validation and controlling rules.
You want to ensure that users can easily navigate a dataBECOME
entry formAN EXCEL
without POWER USER
confusion.

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”.

How To Create An Excel UserForm: Overview


At a basic level, you can create a UserForm in the following 6 simple steps:

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.

2. Add controls to the UserForm.


OK
3. Move or resize the added UserForm controls, as required.
https://powerspreadsheets.com/create-excel-userforms/ 4/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example

4. Customize the UserForm or its controls.


START LEARNING
5. Assign EXCEL
VBA code VBAUserForm.
to the EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
. Display or load the UserForm. Join tens of thousands
7. Close orLOGIN
ACADEMY hide the UserForm.
of Excel Power Users
How To Insert A New UserForm
Get updates and resources to help you be
more efficient and work faster with Excel.
Additionally, (almost) every week I send one
You can insert a UserForm in the following 3 easy steps:
of the following two emails:

1. Go to the Visual Basic Editor by, for example, using the “Alt + F11” keyboard shortcut.
• A worksheet formula template/example; and

2. Go to the Project Explorer, and right-click on the workbook (Project)


• A VBA where you want to insert the
code snippet/example.
UserForm.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy


VBE and Project Explorer and Project
Enter your email here...

BECOME AN EXCEL POWER USER

3. In the context menu displayed by the VBE, go to Insert > 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/ 5/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example

Right-click and Insert and UserForm


START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...


As an alternative to steps #2 and #3 above, you can proceed as follows:
BECOME AN EXCEL POWER USER
1. Select the Project where you want to insert the UserForm.

Project Explorer and Project

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

Go to Insert > 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/ 7/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example

VBE and Insert and UserForm


START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER


Once you complete the process above, Excel the inserts the UserForm. By default, the UserForm contains
an empty dialog box. Notice that, in addition to displaying the UserForm window on the right side of the
screen, the VBE adds the following items to the Project Explorer:

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

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:

Click on the Toolbox button in the VBE toolbar.

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

Go to the View > 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
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

How To Add Controls


START LEARNING EXCEL VBA
To A UserForm WithVBAThe
EXCEL AND VBA TRAINING RESOURCES CODE GENERATOR
Toolbox Join tens of thousands
YouACADEMY LOGIN
can add a control to a UserForm in 3 simple steps: of Excel Power Users
Get updates and resources to help you be
1. Select a control in the Toolbox. more efficient and work faster with Excel.
Additionally, (almost) every week I send one
For example, in the following image, I select a Label. of the following two emails:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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

Join tens of thousands


Alternatively, you can click-and-drag within the UserForm. This allows you to specify the size of the
control.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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...


3. If necessary, you can move or resize the control, using commonly-used methods. You can nd further
details about some of these methods below. BECOME AN EXCEL POWER USER

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:

1. Double-click on the control within 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
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

2. Click on the UserForm, where you want to add the control.


START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
3. Repeat step #2 as required until you've added the number of controls you need. 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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

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

It contains a single tab (Controls) and 16 icons.


START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR

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:
Out of the 16 icons that appear in the Toolbox, 15 are controls you can insert in your UserForms. You can
divide these controls in the following groups:
• A worksheet formula template/example; and

1. Controls that in uence the appearance of your UserForm.


• A VBA code snippet/example.
2. Controls that allow users to enter data, make selections or issue a command.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy


The remaining control is Select Objects. As indicated by its name, Select Objects allows you to select and
manipulate the different elements of your UserForm. Enter your email here...

BECOME AN EXCEL POWER USER

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

Group #1: Controls That In uence The Appearance Of Your


START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
UserForm
This group of control allows you to customize your UserForm.
Join tens of thousands
ACADEMY LOGIN of Excel Power Users
1. Label: Displays a text label. You commonly use labelsGet
to (i)updates
identifyand
a section of thetoUserForm,
resources or (ii)
help you be
display information. more efficient and work faster with Excel.
Additionally, (almost) every week I send one
of the following two emails:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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

Join tens of thousands


3. MultiPage: Displays a container with tabs. This is the control you usually use to create dialog boxes
with tabs.
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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER


4. TabStrip: Displays several tabs within the dialog box.

5. Image: Displays an image.

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

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.

Group #2: Controls That Allow Users ToBECOME


EnterAN EXCEL
Data, POWER USER
Make
Selections Or Issue A Command
This group of controls allow the users of your UserForm to (i) enter data, (ii) make selections, or (iii) issue
commands.

1. TextBox: Displays an input eld. Allows users to enter text or values.

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER


3. ListBox: Displays a list. Users can select 1 or more items from the list, depending on the setting you
specify for the ListBox.MultiSelect property.

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

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...

BECOME AN EXCEL POWER USER

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

In both cases, the idea is the


OK button, same: grouped
(ii) closing/dismissing OptionButtons
this notice or (iii) continuing toare mutually
use/browse exclusive. Therefore, a user
this website.

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

START LEARNING EXCEL


. ToggleButton: VBA
Displays a toggleEXCEL
button.AND VBAcan
Users TRAINING
use thisRESOURCES VBA CODE
button to toggle between GENERATOR
2 states: True
Join tens of thousands
and False. If the ToggleButton is pressed, its value is True. If the ToggleButton isn't pressed, its value
is False.LOGIN
ACADEMY of Excel Power Users
The appearance of a ToggleButton depends on the current state.

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER


7. CommandButton: Displays a button, which users can click. When the user clicks a button, your VBA
Application usually performs an action.

. 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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

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

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:

• A worksheet formula template/example; and

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

How To Select, Move Or ResizeEnter


UserForm Controls
your email here...

And UserForms BECOME AN EXCEL POWER USER


Once you've added a control to a UserForm, you can easily move or resize it. You generally do this with the
mouse. The following are some of the most commonly-used methods to move or resize controls or the
UserForm itself:

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

The UserForm Grid Enter your email here...


When you're working with a UserForm, the VBE usually displays dots forming a grid.
BECOME AN EXCEL POWER USER

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.

You can specify


This website 3(both
uses cookies settings
ours and related to this
from Third Parties) for dot grid: set forth in our Privacy Policy. You accept the use of these cookies by either (i) clicking the
the purposes
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.

1. Whether the grid is visible or not. OK

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

2. The size of the grid elements.


START LEARNING
3. Whether EXCEL
controls VBA
snap EXCEL
to the grid AND VBA TRAINING RESOURCES
or not. VBA CODE GENERATOR

Join tens of thousands


YouACADEMY
determine
of Excel Power Users
these settings from the General tab of the Options dialog. You can get to this tab in the
LOGIN
following 2 easy steps:
Get updates and resources to help you be
more efficient and work faster with Excel.
1. Go to Tools > Options.
Additionally, (almost) every week I send one
of the following two emails:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

2. Within the Options dialog, go to the General tab.

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

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

Join tens of thousands


2. Grid Units: Allows you to set the size of the individual grid elements (the distance between the grid
dots). You
ACADEMY LOGIN of Excel Power Users
do this by specifying the width and height, in points, within the Width and Height elds. The
default value is 6 points for both height and width. The larger the values, the bigger the separation
between grid dots. 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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

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.

The Format Menu Or UserForm Toolbar


OK

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

Join tens of thousands


I describe
ACADEMY theLOGIN
of Excel Power Users
main commands below. First, let's look at the different ways you can access them:

How To Access The Commands In The Format


GetMenu
updatesOr
andUserForm
resources toToolbar
help you be
more efficient and work faster with Excel.
You can access the commands within the Format Menu or Additionally,
UserForm toolbar using
(almost) anyweek
every of theI following
send one 3
methods: of the following two emails:

• A worksheet formula template/example; and


1. Through the Format menu, in the following 2 easy steps:

• A VBA code snippet/example.


1. Select the control(s) you want to manipulate.

2. Go to the Format menu and select the command you want anytime
Unsubscribe to apply.
| 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER 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.

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

Join tens of thousands


2. Through the UserForm toolbar, in the following 3 simple steps:
ACADEMY LOGIN of Excel Power Users
1. If you can't see the UserForm toolbar, make it visible by going to View > Toolbars > UserForm.
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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

2. Select the control(s) you want to work with.

3. Click on the appropriate button in the UserForm toolbar.

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

3. Through a context menu in the following 2 easy steps:

1. Select the control(s) and right-click on them.

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

Lefts: Aligns the selected controls to the left border of the reference control.

Centers: Aligns the (horizontal) center of the selected controls.

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

Join tens of thousands


Middles: Aligns the (vertical) center of the selected controls.
ACADEMY LOGIN of Excel Power Users
Bottoms: Aligns the selected controls to the bottom border of the reference control.
Get updates and resources to help you be
more efficient and work faster with Excel.
To Grid: Snaps the selected control(s) to the grid.
Additionally, (almost) every week I send one
of the following two emails:

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.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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

START LEARNING EXCELthe


Both: Resizes VBAselectedEXCEL ANDtoVBA
controls TRAINING
have the sameRESOURCES
height and sameVBA CODE GENERATOR
width.
Join tens of thousands
ACADEMY LOGIN of Excel Power Users
3. Size to Fit: Auto ts the selected control(s). In other words, the control(s) are resized per their
contents. 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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...


5. Horizontal Spacing: You can use these settings to specify the horizontal spacing between the
BECOME AN EXCEL POWER USER
selected controls. Choose from the following spacing options:

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

Join tens of thousands


Make Equal: Makes the horizontal spaces between the selected controls equal.
ACADEMY LOGIN of Excel Power Users
Increase: Increases the horizontal spacing between the controls.
Get updates and resources to help you be
more efficient and work faster with Excel.
Decrease: Decreases the horizontal spacing between the controls.
Additionally, (almost) every week I send one
of the following two emails:
Remove: Removes the horizontal spacing between the controls.

• A worksheet formula template/example; and

. Vertical Spacing: Allows you to specify the vertical spacing between


• A VBA the selected controls. You can
code snippet/example.
use the same options as when working with Horizontal Spacing (above).

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER 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.
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

Increase: Increases the vertical spacing between the controls.


START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR

Join tens of thousands


Decrease: Decreases the vertical spacing between the controls.
ACADEMY LOGIN of Excel Power Users
Remove: Removes the vertical spacing between the controls.
Get updates and resources to help you be
more efficient and work faster with Excel.
Additionally, (almost) every week I send one
7. Center in Form: Allows you to center the selected control(s) horizontally or vertically within the
of the following two emails:
UserForm.

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

Bottom: Arranges the selected CommandButton(s) on the bottom of the UserForm.

Right: Arranges the selected CommandButton(s) on the right side of the UserForm.

9. Group: Groups the selected 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/ 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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...


10. Ungroup: Ungroups controls that were previously grouped (for example, by using #9 above).
BECOME AN EXCEL POWER 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
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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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.

Bring Forward: Brings the selected control 1 step forward.

Send Backward: Sends the selected control 1 step backward.

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

How To Customize A UserForm Or Its Controls Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...


You customize a UserForm or its controls (all of which are objects) by modifying their properties. You can
specify these properties in 3 ways: BECOME AN EXCEL POWER USER

1. Programmatically, using VBA code.

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.

2. Manually, by manipulating the object within the UserForm window.

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.

3. Manually, using the Properties Window of the VBE.

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

3. Set the new property value. Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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.

UserForm Or Control Properties Vs. Other VBA Properties


Objects within the Excel VBA Object Model have properties. Properties are the attributes, characteristics or
qualities that you can use to describe an object.

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

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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

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
Objects have different properties, although some propertiesofare
thecommonly-shared
following two emails:
by different objects.
Therefore, the appearance of the Properties Window changes depending on the object you select.
• A worksheet formula template/example; and
Additionally, the Properties Window can display the properties of the same object organized per 2 different
• A VBA code snippet/example.
criteria. You select the organization criteria by choosing 1 of the 2 tabs the Properties Window has:

1. Alphabetic: Organizes the properties in alphabetical order.


Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

2. Categorized: Organizes the properties in categories.

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

How To Modify Properties With The Properties Window


START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR

Join tens of thousands


The Properties Window usually contains 2 columns. The left column lists the name of the properties. The
right column shows the current property setting.
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:

• A worksheet formula template/example; and

• A VBA code snippet/example.


Therefore, once you've selected the object you want to work with, you can proceed as follows:

Unsubscribe anytime | 100% privacy | Read our Privacy Policy


1. Identify the property you want to modify using the names that appear in the left column of the
Properties Window. Enter your email here...

BECOME AN EXCEL POWER USER

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.

You can generally enter a new property value inOK


1 of 3 ways:

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.


2. By selecting a setting from a pre-set list of values. Properties that can take a limited list of
values have a drop-down list in the Properties Window. You can easily identify such properties
Unsubscribe anytime | 100% privacy | Read our Privacy Policy
because, when you select one, the VBE displays a drop-down button.
Enter your email here...

BECOME AN EXCEL POWER USER

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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.

Why Modify The Name Property Of Your UserForms Or UserForm


Controls
Each object has its own properties. These properties generally vary from object to object. There are,
however, some
This website uses properties
cookies (both ours andthat areParties)
from Third common to several
for the purposes set forthdifferent
in our Privacyobjects. Commonly-used
Policy. You accept properties
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.
include Name, Width, Height, Left, Right, Value and Caption. In fact, UserForms and all UserForm controls
have the Name property. OK

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

Join tens of thousands


Every time you
ACADEMY of Excel Power Users
add a UserForm to a Project, the Visual Basic Editor assigns a default name:
LOGIN

Get updates and resources to help you be


“ UserForm# more efficient and work faster with Excel.
Additionally, (almost) every week I send one
of the following two emails:
“#” is an integer that starts at 1 and increases sequentially. Therefore, the rst UserForm you add is
UserForm1. The second is UserForm2. The third is UserForm3. And so on…
• A worksheet formula template/example; and

This may look familiar. Excel uses similar naming conventions for workbooks,
• A VBA worksheets, and regular VBA
code snippet/example.
modules (among others).

Unsubscribe anytime | 100% privacy | Read our Privacy Policy


That same rule applies to the controls within a UserForm. For example, if you're working with Label controls,
Enter
the rst Label is named Label1. The second is Label 2. And so on… your email here...

You can nd the name of a UserForm or UserForm control by BECOME


checking itsAN EXCEL
Name POWER
property in the USER
Properties
Window. This property is important:

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.

How To Name UserForms Or UserForm Controls


Several of the general naming rules, such as those that apply to properties and Sub procedures, are also
applicable to UserForms and UserForm controls. The following are the main rules you may want to
consider when setting the names of your UserForm and 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
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.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

UserForm Control Pre x


Enter your email here...
CheckBox chk
BECOME AN EXCEL POWER USER
ComboBox cbx or cmb

CommandButton cmd

Frame fra

Image img

Label lbl

ListBox lst or lbx

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

ToggleButton Join tens


tgb of thousands
ACADEMY LOGIN
UserForm
of Excel Power Users
frm or uf
Get updates and resources to help you be
more efficient and work faster with Excel.

How To Remove Controls From A UserForm


Additionally, (almost) every week I send one
of the following two emails:

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.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER 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.

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...


How To Assign VBA Code To A UserForm
BECOME AN EXCEL POWER USER
Once you complete the design of your UserForm, you must create the macros that power it and respond to
the user's actions. You can create and assign macros to a UserForm in the following 2 easy steps:

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.

What Is A UserForm Code Window


OK And Why You Work With It

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

Join tens of thousands


UserForms
ACADEMY LOGIN
such as Worksheets or Workbooks.
of Excel Power Users
are class objects have a code module. This is like what occurs with other object classes,

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.

• A worksheet formula template/example; and


Notice the difference between the following:
• A VBA code snippet/example.
The event-handler procedures which are executed when a user works with the UserForm. These
event-handler procedures are stored within the UserForm Code window.
Unsubscribe anytime | 100% privacy | Read our Privacy Policy
The procedure(s) that control the display of the UserForm. These procedures are usually stored within
a regular module, and never within the UserForm CodeEnter your
module. Youemail here...
can read more about how to
display a UserForm further below.
BECOME AN EXCEL POWER USER
How To Toggle Between The Code And UserForm Windows
Within the VBE, you work with 2 UserForm windows or modules:

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

You can toggle back and forth between these 2 windows with any of the 3 following features:

1. The “F7” and “Shift + F7” keyboard shortcuts:

“F7” displays the Code window.

“Shift + F7” displays the UserForm window.


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/ 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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

Go to View > Object to see the UserForm window.

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Right-click the UserForm and select View Code toEnter


go to your email
the Code here...
window.

Right-click the UserForm and select View Object toBECOME AN EXCEL


go to the UserForm POWER USER
window.

If you want to go to the UserForm window, you can generally double-click the UserForm within the Project
Explorer.

Why UserForms Work With Event-Handler Procedures


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

When working with UserForms,


OK button,your main purpose
(ii) closing/dismissing is usually
this notice to allow
or (iii) continuing usersthistowebsite.
to use/browse enter information or provide
other input for your macros. Therefore, your code must be able to respond to what the user does with the
OK
UserForm. You do this by relying on events.
https://powerspreadsheets.com/create-excel-userforms/ 59/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example

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

applicable to the event-handler procedures you create to deal with UserForms.


• A VBA code snippet/example.

The following are 3 of these principles, as they apply to UserForms:


Unsubscribe anytime | 100% privacy | Read our Privacy Policy

1. The basic structure of the names of event-handler procedures is composed


Enter your of the following 3 (or 4)
email here...
items:
1. The UserForm or UserForm control. BECOME AN EXCEL POWER USER
2. An underscore (_).
3. The event that triggers the event-handler procedure.
4. In some cases, an argument list.
2. If you don't enter the appropriate declaration statement, following the structure I describe in #1 above,
the procedure doesn't work.
3. However, you don't have to learn the exact names or declaration statements for event-handler
procedures. You can get the VBE to enter the appropriate declaration statement by using either of the
2 processes I describe in the following section.

How To Enter The Declaration Statement For An Event-Handler Procedure


You can get the VBE to enter the appropriate declaration statement for an event-handler procedure in the
following 9 easy steps:

1. Go to the UserForm Code window for the appropriate 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/ 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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

3. Select the object you want to work with.

In the screenshot below, I select 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/ 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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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.

If you want to work with another event, proceed to step #6.


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.
. Click on the Procedure drop-down list, which appears at the top right side of the UserForm Code
window. The label of this drop-down is “(Declarations)”.
OK

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

7. Select the event you want to work with.

In the screenshot below, I select the Initialize 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/ 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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

. 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.

Use these statements as the basis to code your event-handler procedure.


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/ 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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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”.

In the screenshot below, I select a CommandButton.


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/ 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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...


2. The VBE takes you to the UserForm's Code window. Additionally, the VBE enters the declaration and
End statements for the Sub procedure that handles the BECOME
default event
AN of EXCEL
the object, and places
POWER USERthe
cursor between these 2 statements.

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

2. Select the event you want to work with.

In the screenshot below, I select the double click (Dblclick) 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/ 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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

How To Refer To UserForm Controls Within Your Code


UserForms and UserForm controls are objects. You generally refer to them by using their Name property.
The Name property is the rst in an alphabetically-organized Properties Window.

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

Join tens of thousands


You can see the UserForm as the parent object of the controls within it. Therefore, the basic control
reference
ACADEMYstructure
LOGIN is as follows: of Excel Power Users
Get updates and resources to help you be
“ UserForm.Control more efficient and work faster with Excel.
Additionally, (almost) every week I send one
of the following two emails:
“UserForm” is the UserForm object. “Control” is the control you're referring to.

• A worksheet formula template/example; and


However, you usually refer to controls within event-handler procedures that are stored in the UserForm's
Code module. Therefore, you can simplify the reference by •omitting a reference
A VBA code to the UserForm. In this
snippet/example.
case, you can refer to a control as follows:

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

“ Control
Enter your email here...

BECOME AN EXCEL POWER USER


An additional alternative is to use the Me keyword to refer to the UserForm. In this case, the reference
structure is as follows:

“ Me.Control

How To Display Or Load A UserForm


You can display a UserForm in the following 2 easy steps:

1. Go to the appropriate module.

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.

• A worksheet formula template/example; and


You can also include the Show method in event-handler procedures. In such cases, the UserForm is
displayed when the relevant event occurs. • A VBA code snippet/example.

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...

“ Load UserForm BECOME AN EXCEL POWER USER

“UserForm” is a UserForm object.

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).

Where To Store The Macro That Displays A 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
You use the Show methodOKwithin the
button, (ii) procedurethis
closing/dismissing where
notice oryou want to
(iii) continuing display this
to use/browse thewebsite.
UserForm. This procedure is
usually stored within a regular VBA module. You don't store the macro that displays the UserForm in the
UserForm Code window itself. OK

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.

• A worksheet formula template/example; and


Since the code within the UserForm is never executed if the UserForm isn't displayed, you can't store the
code that determines when the UserForm is displayed in the
• AUserForm
VBA codeCode module. If you store the code
snippet/example.
that displays a UserForm within the UserForm itself, the UserForm is never displayed.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy


How To Display A UserForm From The VBE
Enter your email here...
You can display a UserForm while working in the VBE by using the Run Macro (Sub/UserForm) command.
You can execute the Run Macro (Sub/UserForm) command inBECOME
any of the AN EXCEL
following POWER USER
3 ways:

1. Clicking on the Rub Macro button in the VBE toolbar.


2. Going to Run > Run Macro.
3. Using the “F5” keyboard shortcut.

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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

“UserForm” is a UserForm 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.

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

How Is The Control Flow When Excel Displays A UserForm


At a basic level, once the Show method of the UserForm object is called, Excel goes through the following
6-step process:

1. Displays 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/ 81/122
5/19/2021 Create Excel UserForms For Data Entry In 6 Easy Steps: Tutorial And Practical Example

2. Waits for the user to work with the UserForm.


START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR

Join tens of thousands


3. The interaction of the user with the UserForm usually triggers an event associated to 1 of the controls
within the
ACADEMY of Excel Power Users
UserForm. Therefore, the applicable event-handler procedure is executed.
LOGIN

4. Once an event-handler procedure runs, control returnsGet updates


to the and resources to help you be
UserForm.
more efficient and work faster with Excel.
Additionally, (almost) every week I send one
5. Eventually, the UserForm is closed or dismissed by the user.
of the following two emails:

. 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.

How To Close Or Hide A UserForm


There are few different ways in which a UserForm can be closed or hidden.

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

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

Enter your email here...


1. QueryClose: Occurs before the UserForm is closed.
BECOME
2. Terminate: Occurs after the UserForm is unloaded and when AN EXCEL
the UserForm POWER
is removed USER
from memory.

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

“UserForm” is a UserForm object.

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

“UserForm” is a UserForm object.


START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR

Join tens of thousands


In both cases,LOGIN
ACADEMY of Excel Power Users
if the procedure containing this statement is stored within the UserForm Code module, you
can use the Me keyword. In such a case, you can always use the same statement regardless of the Name
property of the UserForm. Additionally, you can replace the Get updatesabove
statements and resources to help you be
with the following:
more efficient and work faster with Excel.
Additionally, (almost) every week I send one
“ Unload Me of the following two emails:

Me.Hide • A worksheet formula template/example; and

• A VBA code snippet/example.


You generally use the Unload statement only after all the UserForm instructions and statements have
been carried out. This includes retrieving the input data from the UserForm and carrying out any necessary
Unsubscribe anytime | 100% privacy | Read our Privacy Policy
actions. If you fail to do this, the UserForm has no real effect, other than displaying the UserForm itself.
Enter your email here...
I don't cover the topic of retrieving input from a UserForm in detail within this blog post. But you can see
some code examples further below. BECOME AN EXCEL POWER USER

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.

As explained in the Excel 24-Hour VBA Trainer:


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/ 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.

This UserForm Tutorial is accompanied by an Excel workbook example.


of the If you
following twowant to follow the steps I
emails:
describe below, get immediate free access to this workbook by clicking the button below.
• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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

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:

• A worksheet formula template/example; and

• 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.

3. Go to Insert > UserForm.


Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER 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.

The Visual Basic Editor creates the following blank UserForm.


OK

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

Step #2: Add Controls To The UserForm


The purpose of the example UserForm example is to serve for data entry. There are only 2 required entries:

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

1 SpinButton, to specify the number of units sold.


START LEARNING
1 TextBox, EXCEL the
to display VBAnumberEXCEL AND
of units VBAspeci
sold TRAINING
ed byRESOURCES VBA CODE GENERATOR
clicking on the SpinButton.
1 Label for the TextBox. Join tens of thousands
5 OptionButtons,
ACADEMY LOGIN of Excel Power Users
to choose the appropriate item. In this example, you use OptionButtons because you
want to ensure that the user can select only 1 item (not several).
1 Frame, for the OptionButtons. Get updates and resources to help you be
more
2 CommandButtons: A Record Entry and a Close Form efficient and work faster with Excel.
button.
Additionally, (almost) every week I send one
of the following two emails:
Add the SpinButton, TextBox, Label and Frame controls following the same 2-step process:

• A worksheet formula template/example; and


1. Select the control in the Toolbox.
2. Click on the UserForm, in the location where you want• to add the
A VBA control.
code snippet/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

Join tens of thousands


1. Frame. LOGIN
ACADEMY
2. OptionButtons.
of Excel Power Users
3. Label. Get updates and resources to help you be
4. TextBox. more efficient and work faster with Excel.
Additionally, (almost) every week I send one
5. SpinButton.
of the following two emails:
. CommandButtons.

• A worksheet formula template/example; and


The following GIF shows the process I describe above:

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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.

Step #3: Move Or Resize The 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
OK button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.
Use the grid and several commands in the Format menu to arrange the controls within the UserForm. The
exact commands you use vary depending on the exact
OKsituation you're in.

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

For this example, do the following:


START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR

Join tens of thousands


1. Arrange the vertical spacing between the different OptionButtons and align them to the left, as
follows:LOGIN
ACADEMY
1. Select all the OptionButtons.
of Excel Power Users
2. Go to Format > Vertical Spacing > Remove. Get updates and resources to help you be
3. Go to Format > Vertical Spacing > Increase. more efficient and work faster with Excel.
Additionally, (almost) every week I send one
4. Change the reference control by holding the Ctrl key while clicking on an OptionButton that has
of the following two emails:
the appropriate alignment.
5. Go to Format > Align > Lefts.
• A worksheet formula template/example; and
2. Reduce the height of the Frame used to group the OptionButtons. Do this by clicking on and dragging
on its lower center sizing handle. • A VBA code snippet/example.
3. Move the Label, TextBox, SpinButton and CommandButtons up, so that they're closer to the lower
edge of the Frame. Do this by selecting all the controls and dragging them with the mouse.
Unsubscribe anytime | 100% privacy | Read our Privacy Policy
4. Align all controls, except the SpinButton and the CommandButton on the right side of the UserForm,
to the left. Do this as follows: Enter your email here...
1. Select all controls, excluding the SpinButton and the right-hand CommandButton.
2. Go to Format > Align > Lefts. BECOME AN EXCEL POWER USER
5. Make the SpinButton the same height as the TextBox and align both controls, as follows:
1. Select the SpinButton and the TextBox.
2. Go to Format > Make Same Size > Height.
3. Go to Format > Align > Rights.
4. Go to Format > Align > Tops.
. Arrange the vertical spacing between the TextBox and the left-hand CommandButton, as follows:
1. Select the left-hand CommandButton and the TextBox.
2. Go to Format > Vertical Spacing > Remove.
3. Go to Format > Vertical Spacing > Increase.
7. Align the CommandButtons, as follows:
1. Select the CommandButtons.
2. Go to Format > Align > Tops.
3. Go to Format > Horizontal Spacing > Remove.
4. Go to Format > Horizontal Spacing > Increase.
. Decrease the height of the UserForm by using its lower center sizing handle.
9. Decrease the width of both the Frame and the UserForm. In both cases, click and drag on their
respective right center 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.

The following GIF shows the 9-step process I describe above:


OK

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Step #4: Customize The UserForm And Its Controls


Unsubscribe anytime | 100% privacy | Read our Privacy Policy

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

1. Select the object to modify.


START LEARNING
2. Go to EXCELWindow
the Properties VBA EXCEL
and AND
select theVBA TRAININGproperty.
appropriate RESOURCES VBA CODE GENERATOR

Join tens of thousands


3. Double-click on the current property setting, and (when required) replace it with a new one. With some
of the properties
ACADEMY of
LOGIN used in this example Default, Cancel, Enabled
you to cycle through the available values (True and False).
Excel Power Users
and Locked), double-clicking allows

Get updates and resources to help you be


more efficient
The following table shows the new Name and Caption properties for eachand work
of the faster Iwith
objects. use Excel.
“n.a.” to
Additionally, (almost) every week I send one
indicate the cases where a property isn't a member of the object.
of the following two emails:

Original Object Name Name Property • A worksheet formulaCaption Property


template/example; and

UserForm1 userFormSalesEntry Enter sales data


• A VBA code snippet/example.

Label1 labelUnits No. of units sold


Unsubscribe anytime | 100% privacy | Read our Privacy Policy

TextBox1 textBoxUnits n.a.


Enter your email here...
SpinButton1 spinButtonUnits n.a.
BECOME AN EXCEL POWER USER
Frame1 frameItem Item

OptionButton1 optionButtonSurfaceStudio Surface Studio

OptionButton2 optionButtonSurfaceBook Surface Book

OptionButton3 optionButtonSurfacePro4 Surface Pro 4

OptionButton4 optionButtonXboxOneS Xbox One S

OptionButton5 optionButtonXboxOne Xbox One

CommandButton1 commandButtonRecordEntry Record Entry

CommandButton2 commandButtonCloseForm Close Form

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

for the objects you refer to within the code.


OK

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.


Step #5: Assign VBA Code To The UserForm
Unsubscribe anytime | 100% privacy | Read our Privacy Policy
My focus in this UserForms Tutorial are UserForms, not VBA code. My purpose is to show you how you can
use some of the VBA constructs I explain in the rst section of this blog post, such as the Unload
Enter your email here...
statement.
BECOME AN EXCEL POWER USER
Therefore, the Sub procedure examples below are very simple. You can use more sophisticated macros and
nd several Tutorials that focus on VBA code in the Archives.

In this step, you create the following 3 macros:

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:

1. Double-click the Record Entry CommandButton.

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Because of this, the VBE does the following:


Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Takes you to the Code window.


Enter your email here...
Enters the declaration and End statements for a Sub procedure triggered by the Click event of
BECOME AN EXCEL POWER USER
the CommandButton object (Private Sub commandButtonRecordEntry_Click()). The Click event
occurs when the user clicks on the CommandButton.

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

Join tens of thousands


2. Enter the
ACADEMY LOGIN of Excel Power Users
VBA code for the Sub procedure triggered when the user clicks on the Record Entry
CommandButton. This is the main Sub procedure and carries out most of the work you require.
Get updates and resources to help you be
more
3. Click on the Object drop-down list at the top left side of the efficient
UserForm and work
Code faster with
window, Excel. the
and select
Additionally, (almost) every week I send one
SpinButton control (spinButtonUnits).
of the following two emails:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER 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.

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

Join tens of thousands


The VBE enters the declaration and End statements for a Sub procedure triggered by the Change
event ofLOGIN
ACADEMY of Excel Power Users
the spinButtonUnits object (Private Sub spinButtonUnits_Change()). The Change event
occurs when the Value property of the SpinButton changes. The Value property, in turn, changes when
the user clicks any of the arrows of the SpinButton. 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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

. Click on the Procedure drop-down list at the top right sideUnsubscribe


of the UserForm
anytime | 100% Code
privacy | Window, and
Read our Privacy select
Policy

the Initialize event.


Enter your email here...

BECOME AN EXCEL POWER 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.

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

7. Delete the opening and closing statements entered by the VBE in step #5 above (Private Sub
Enter your email here...
UserForm_Click()).

BECOME AN EXCEL POWER USER

. 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.

Sub Procedure #1: Private Sub UserForm_Initialize()


OK

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER


This macro sets the default values and selections for several controls within the UserForm, as follows:

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.

Let's look at each line of code within this macro:

Lines #1 And #5: With Me | End With


Opening and closing statements of a With… End With block.
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 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

Line #2: .textBoxUnits.Text = 0


START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
Sets the default value of the TextBox to 0. This default number of units (0) is recorded when the user fails to
specify one through the SpinButton control. Join tens of thousands
ACADEMY LOGIN of Excel Power Users
You achieve this by setting the Text property of the TextBox (.textBoxUnits.Text) to 0.
Get updates and resources to help you be
more efficient and work faster with Excel.
Line #3: .spinButtonUnits.Value = 0 Additionally, (almost) every week I send one
of the following
Sets the default value of the SpinButton to 0. This value matches two
the default emails:
value of the TextBox (line #2
above).
• A worksheet formula template/example; and

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.

Line #4: .optionButtonSurfaceStudio.Value = True


Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Selects (by default) the OptionButton that corresponds to theEnter your


Surface email here...
Studio.

BECOME AN EXCEL POWER USER


You achieve this by setting the Value property of the rst OptionButton (Surface Studio) to True. The Value
property allows you to specify whether the OptionButton is selected (True).

Private Sub commandButtonRecordEntry_Click()


The following is the VBA code within the Sub procedure executed when the user clicks the Record Entry
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/ 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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

This Sub procedure goes through the following process:

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

2. Selecting the default OptionButton (for Surface Studio).


START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR

Join tens of thousands


The macro doesn't carry any data validation checks, nor handles any possible errors. For example, it doesn't
check whether
ACADEMY of Excel Power Users
the user has entered the number of units using the SpinButton. In this example, those
LOGIN
checks are mostly handled by the SpinButton and the properties of the TextBox you modify in step #4
above, as follows: Get updates and resources to help you be
more efficient and work faster with Excel.
Additionally, (almost) every week I send one
The user can't enter data directly in the TextBox. This is a consequence of the values you set for the
of the following two emails:
Enabled (False) and Locked (True) properties of the TextBox in step #4 above.

• A worksheet formula template/example; and


The number of units displayed on the TextBox is dependent on the SpinButton. In other words, the
user speci es the number of units through the SpinButton.
• A VBAThecode
TextBox simply displays the current
snippet/example.
number of units.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy


You achieve this through an event-handler procedure triggered by the Change event of the SpinButton
Enter
object. You can nd an example of such code below (Sub your email
procedure #3). here...

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:

Lines #1 And #2: Dim myWorksheet As Worksheet |Dim myFirstBlankRow As Long


Use the Dim keyword to declare 2 variables:

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.

Line #3: Set myWorksheet = Worksheets(“Excel UserForm data entry”)


Uses the Set keyword to assign a worksheet (Excel UserForm data entry) to an object variable
(myWorksheet).
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.

Lines #4 And #21: With myWorksheet | End With


OK

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:

1. The number of the last cell with data in the worksheet• is


A found (.Cells.Find(What:=”*”,
worksheet formula template/example; and
LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row).
2. A value of 1 is added. This addition returns the number
• AofVBA
the row
codebelow the last cell with data or, in
snippet/example.
other words, the rst empty row in the worksheet.
Unsubscribe anytime | 100% privacy | Read our Privacy Policy

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...

BECOME AN EXCEL POWER USER


1. The Worksheet.Cells property (.Cells) returns all the cells within myWorksheet.
2. The Range.Find method (Cells.Find) is used to search for the last cell with data within myWorksheet.
The parameters of the Range.Find method, which are within parentheses, are set as follows:
1. What: “*”. The data you're searching for. The asterisk (*) acts as wildcard. Therefore, the Find
method searches for any character sequence.
2. LookIn: xlFormulas. The type of data you're searching in. xlFormulas results in VBA searching
(looking) in the cell formulas.
3. LookAt: xlPart. Speci es whether the Find method matches the cell contents in their entirety, or
just a part of them. xlPart results in Excel doing a partial match.
4. SearchOrder: xlByRows. Speci es whether the search is carried out by rows or by columns.
Since you're looking for the last row, you set this to xlByRows.
5. SearchDirection: xlPrevious. The direction (next or previous) in which the search is carried. In
this case, you set the argument so that Excel searches for the previous (xlPrevious) match.

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

Let's analyze the object to which statements refer to:


START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR

Join tens of thousands


The Cells property (.Cells) works with the object speci ed in the opening statement of the outer With…
End With
ACADEMY block (line #4 above). That object is myWorksheet.
LOGIN of Excel Power Users
The Cells property returns a single cell. That's the cell located on the rst empty row
(myFirstBlankRow) and the rst column (1 or A) of theGet updates and
worksheet. This resources to help
cell is where youdata
the next be
entry for Item is recorded. more efficient and work faster with Excel.
Additionally, (almost) every week I send one
of the following two emails:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

Lines #7 And #18: Select Case True | End Select


Opening and closing of a Select Case statement.

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).

Lines #8 Through #17: Case optionButtonSurfaceStudio.Value | .Value = “Surface Studio” |


Case optionButtonSurfaceBook.Value | .Value = “Surface Book” | Case
optionButtonSurfacePro4.Value | .Value = “Surface Pro 4” | Case
optionButtonXboxOneS.Value | .Value = “Xbox One S” | Case optionButtonXboxOne.Value |
.Value = “Xbox One”
Line #8, #10, #12, #14 and#16 are the expressions against which VBA seeks to match the test expression
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
(True) from line #7 above. OK
The statement
button, that VBA
(ii) closing/dismissing executes
this notice is the
or (iii) continuing one following
to use/browse the expression that returns
this website.

True and, therefore, matches the test expression.


OK

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

Join tens of thousands


ACADEMY
Rows # LOGIN
Expression Statementof Excel
that's executedPower
if ExpressionUsers
= True

Get updates and resources to help you be


8 and 9 optionButtonSurfaceStudio.Value .Value = “Surface Studio”
more efficient and work faster with Excel.
10 and 11 optionButtonSurfaceBook.Value .Value =Additionally, (almost) every week I send one
“Surface Book”
of the following two emails:
12 and 13 optionButtonSurfacePro4.Value .Value = “Surface Pro 4”
• A worksheet formula template/example; and
14 and 15 optionButtonXboxOneS.Value .Value = “Xbox One S”
• A VBA code snippet/example.
16 and 17 optionButtonXboxOne.Value .Value = “Xbox One”

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Notice the following: Enter your email here...

BECOME AN EXCEL POWER USER


1. The structure of all the groups of statements above is identical.
2. First, you have the expression that VBA seeks to match with the test expression (True).
1. The OptionButton.Value property returns True if the OptionButton is selected.
2. The OptionButtons used in this example are grouped. Therefore, when the user selects 1 option,
the other options are automatically de-selected. In other words, only 1 OptionButton can be
selected.
3. Because of #1 and #2 above, the expression that matches the test expression is that which
corresponds to the OptionButton selected by the user.
3. Second, you have the statement that VBA executes when the corresponding expression is True.
1. The Value property (.Value) works with the object speci ed in the opening statement of the
With… End With block (line #6). That object is the cell where the next entry for Item goes.
2. The executed statement sets the Value property of the relevant cell to be equal to a string. This
string is the name of one of the Items.

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.

Surface Studio Surface Studio


OK

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

Surface Book Surface Book


START LEARNING EXCEL VBA EXCEL AND VBA TRAINING RESOURCES VBA CODE GENERATOR
Surface Pro 4
Join tens of thousands
Surface Pro 4

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

• A VBA code snippet/example.


Let's see how this works:

Unsubscribe anytime | 100% privacy | Read our Privacy Policy


1. The statements sets the Value property of a cell (.Cells(myFirstBlankRow, 2).Value =) to be equal to
the Value property of the UserForm TextBox (Me.textBoxUnits.Value). The Value property of the
Enter your email here...
TextBox is determined by the SpinButton. This part of the process is controlled by the Sub procedure
#3 I explain below. BECOME AN EXCEL POWER USER
2. The rst part of the statement (.Cells(myFirstBlankRow, 2)) works as follows:
1. The Cells property (.Cells) works with the object speci ed in the opening statement of the With…
End With block (line #4). That object is represented by myWorksheet.
2. The Cells property returns a single cell. This cell is located on the rst empty row
(myFirstBlankRow) and the second column (2 or B) of the worksheet. That's the cell where the
next data entry for Units Sold is recorded.

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

Join tens of thousands


TheACADEMY
UserForm_Initialize
follows:
LOGIN of Excel Power Users
macro sets the default values and controls of certain UserForm controls, as

Get updates and resources to help you be


TextBox: 0. more efficient and work faster with Excel.
Additionally, (almost) every week I send one
SpinButton: 0.
of the following two emails:
OptionButton selection: Surface Studio.

• A worksheet formula template/example; and


In other words, by calling the UserForm_Initialize Sub procedure, you reset the values and selections within
the UserForm to their defaults. This ensures that the UserForm is ready
• A VBA codefor a new entry.
snippet/example.

Sub Procedure #3: Private Sub spinButtonUnits_Change()


Unsubscribe anytime | 100% privacy | Read our Privacy Policy

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:

BECOME AN EXCEL POWER USER

This macro consists of a single VBA statement:


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.

“ textBoxUnits.Value = Me. spinButtonUnits.Value


OK

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:

• A worksheet formula template/example; and


1. Go to a module different from the UserForm's code module.
2. Create a Sub procedure that calls the Show method of the UserForm object.
• A VBA code snippet/example.
3. Assign a keyboard shortcut to the displayUserForm macro.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy


Let's go through each of these steps:

Enter your email here...


Step #1: Go To A Module
BECOME AN EXCEL POWER USER
In this example, store the macro that displays the UserForm in a standard module (Module1).

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

Step #2: Create A Sub Procedure That Calls The Show Method Of The UserForm
Object
Create the following macro (displayUserForm):

displayUserForm consists of the following single statement:


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.

“ 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

Join tens of thousands


Step #3: Assign A Keyboard Shortcut To The displayUserForm Macro
ACADEMY LOGIN
For this example, execute the displayUserForm Sub procedure with a keyboard shortcut. Make this of Excel Power Users
assignment in the following 4 easy steps: Get updates and resources to help you be
more efficient and work faster with Excel.
1. Open the Macro dialog box by, for example, using the Additionally,
“Alt + F8” keyboard shortcut.
(almost) every week I send one
of the following two emails:
2. Within the Macro dialog box, select the appropriate macro (displayUserForm) and click the Options
button. • A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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.

In this example, assign the keyboard shortcut “Ctrl + Shift + A”.


OK

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...


4. Close the Macro dialog box.

BECOME AN EXCEL POWER 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.

Step #7: Close The UserForm OK

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

Get updates and resources to help you be


2. Double-click on the appropriate UserForm module (userFormSalesEntry).
more efficient and work faster with Excel.
Additionally, (almost) every week I send one
of the following two emails:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.


Because of this, the VBE does the following:
Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Takes you to the UserForm's Code window.


Enter your email here...
Enters the declaration and End statements for a Sub procedure triggered by the Click event of
the commandButtonCloseForm object (Private Sub commandButtonCloseForm_Click()).
BECOME AN EXCEL POWER 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.

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

This Sub procedure has the following single statement:


Enter your email here...

“ Unload Me BECOME AN EXCEL POWER USER

The Unload statement unloads the UserForm from memory. This results in the dialog box being dismissed.

UserForm For Data Entry In Action


You can enter data with the UserForm example in the following 5 simple steps:

1. Use the “Ctrl + Shift + A” keyboard shortcut.

2. Excel displays 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/ 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.

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

4. Repeat step #3 as many times as required, depending on the number of entries you want to make.

5. To close the UserForm, press the Close or Close Form button.

The GIF below


This website shows
uses cookies theand
(both ours UserForm in action.
from Third Parties) Notice
for the purposes how:
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.

Every time I click the Record Entry button, the entry


OK is recorded in the table.

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...

BECOME AN EXCEL POWER USER

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:

What is a UserForm, and why are they useful.


The simple 6-step process you can use to create a UserForm for data entry.
How to insert and customize UserForms.
What are UserForm controls, and how you work with them. This includes, among others, how to add,
select, move, resize, customize and remove controls.
How to create the macros that power your UserForms. This includes the VBA code you use to both: (i)
display, load, close and hide UserForms, and (ii) respond to the user's actions within the UserForm.

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

immediate free access to OK


this workbook by clicking the button below.
button, (ii) closing/dismissing this notice or (iii) continuing to use/browse this website.

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...


In practice, you're likely to work with more complex UserForms that (i) gather more data, (ii) use additional
controls, and (iii) work with more complex VBA code. In mostBECOME
cases, the basic principles
AN EXCEL and constructs
POWER USER
you've learned about by reading this UserForms Tutorial continue to apply.

Books Referenced In This UserForms Tutorial


Alexander, Michael and Kusleika, Dick (2016). Excel 2016 Power Programming with VBA. Indianapolis,
IN: John Wiley & Sons Inc.
Goldmeier, Jordan (2014). Advanced Excel Essentials. New York City, NY: Apress.
Mans eld, Richard (2016). Mastering VBA for Microsoft O ce 2016. Indianapolis, IN: John Wiley &
Sons Inc.
Urtis, Tom (2015). Excel VBA 24-Hour Trainer. Indianapolis, IN: John Wiley & Sons Inc.

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

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:

• A worksheet formula template/example; and

• A VBA code snippet/example.

Unsubscribe anytime | 100% privacy | Read our Privacy Policy

Enter your email here...


I publish a lot of Tutorials and resources about Microsoft About | Contact
Excel and VBA. Here are my top 3 picks:
BECOME AN EXCEL POWER USER
1. Free VBA Course: VBA Basics

2. Excel Keyboard Shortcuts

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

You might also like