UserForm Controls

Add to Favorites
Author: | Edits: don

This tutorial gives you an overview of what a UserForm Control is and how to add them to your form.

Sections:

What is a UserForm Control?

Adding a Control to a UserForm

List of Controls for UserForms

Notes

What is a UserForm Control?

Controls are the things that you see on a UserForm; they are the buttons, the text, the input areas, the tabs, and so on. Controls are the building blocks of the UserForm.

Without any Controls, the UserForm would just be a gray square with nothing on it.

Adding a Control to a UserForm

To make a UserForm do much of anything, we have to add a Control to it. In this section, I'll show you how to add, edit, and manage controls.

Show the UserForm

Make sure the UserForm is visible.

Go to the VBA window (Alt + F11) and double-click the UserForm from the Project window on the left side of the screen - if you don't see the Project window, hit Ctrl + R and it will appear.

Show the Toolbox

Click the UserForm and make sure that Toolbox appears; it's a small box that contains the Controls for the UserForm. If you don't see it, go to ViewToolbox and it will appear.

ebbab7d02475e3770e022262686ba20f.jpg

From the Toolbox, click the control that you want to add.

Add the Control

Let's add a simple Label.

Click the button for the Label in the Toolbox and then move your mouse over the UserForm and click and drag the mouse over where you want the item to appear.

320b4e914ceb2b76397e51b22592c6a9.png

When you release the mouse button, the Control will appear.

28bf8aa0562533bc80daa031f15666df.png

Now, you have a new item in your UserForm.

Resize and Move the Control

To change the size of it, simple select the desired Control and click the white blocks around the edges and drag the mouse until you have the desired size.

37080daa3d6cb88a2c7e0542940ce198.png

da5a82f323b1a6d901efbbc0f8452392.png

To move the Control, click the edge of it and drag it around the UserForm.

7f6ed29d6cd11fd808df4ae287df3948.png

Control Properties

The Properties window is where you find everything that defines a Control. To view it, first select the Control and look to the left side of the VBA window.

If the Properties window doesn't appear, hit F4 to show it.

4ef91d3bfc018893a80026497ec148de.png

There, you can change the name of the Control, which is used to reference it with macros, the text displayed in the Control, the appearance of the displayed text, if the Control is even visible, and much more.

These are the most often used properties for Controls:

(Name) - the name of the Control that you will use in VBA in order to do something with it. For instance, you need to know the name of a TextBox in order to get the user's input from it.

Caption - the text that will appear in or on the Control. For a button, this is what appears as the button's text; for a Label, this is the text that appears within the label.

Font - click this section and then the button with the 3 dots that appears and you can control the size and appearance of the text within the Control.

There are many other options that you can change for a Control, and those will be covered in more depth in another tutorial.

Remove the Control

To remove a Control, simply click it and hit the Delete key or Right-click it and select Delete.

You can always hit Ctrl + Z to undo the deletion if you made a mistake.

Common Controls used in UserForms

The most common Controls are the LabelCommandButtonTextBox, and CheckBox.

Here is what they might look like on the UserForm.

ba5f953292fd9b86ce9815bff5924747.png

In the VBA window in design mode, it looks like this:

e6b8b71ec4eb479de790bdaf394e0977.png

List of Controls for UserForms

This is a list of all of the Controls that you can add to a UserForm.

(eventually, each Control will have a link to its own tutorial)

  1. CheckBox
  2. ComboBox
  3. CommandButton
  4. Frame
  5. Image
  6. Label
  7. ListBox
  8. MultiPage
  9. OptionButton
  10. RefEdit
  11. ScrollBar
  12. SpinButton
  13. TabStrip
  14. TextBox
  15. ToggleButton

Notes

Controls are what make a UserForm useful. This tutorial is supposed to serve as an introduction to these Controls. I recommend that you play around with them and see what works best for your situation.

In later tutorials, you will learn how to do things with these controls, such as get data from them and put data into them.

Make sure to download the sample file to see these examples in Excel. However, in this case, the UserForm will not actually do anything; it simply illustrates the display of a few Controls.

Question? Ask it in our Excel Forum


Downloadable Files: Excel File

Similar Content on TeachExcel
UserForm Controls Events
Tutorial: Explanation of Events for Controls in UserForms in Excel. This includes what they are, how...
Create UserForm Control Templates
Tutorial: How to create a UserForm Controls template that will allow you to quickly add pre-formatte...
UserForm Events
Tutorial: Explanation of UserForm Events in Excel. This includes what they are, how to use them, and...
UserForm Properties List and Explanation
Tutorial: This is a listing of all properties for the UserForm in Excel. Each property includes an e...
Loop Through Controls in a UserForm
Tutorial: How to loop through all controls in a UserForm; this allows you to do things like get valu...
UserForm Control Properties Overview
Tutorial: Overview of Control properties in UserForms; this includes what they are, how to change th...
Tutorial Details
Downloadable Files: Excel File
Similar Content
UserForm Controls Events
Tutorial: Explanation of Events for Controls in UserForms in Excel. This includes what they are, how...
Create UserForm Control Templates
Tutorial: How to create a UserForm Controls template that will allow you to quickly add pre-formatte...
UserForm Events
Tutorial: Explanation of UserForm Events in Excel. This includes what they are, how to use them, and...
Excel Forum