fbpx
Search
Close this search box.
Excel VBA - Tutorials, Examples, Information & Resources
Excel VBA > Examples Videos VBA Tips User Forms & Controls Books References Training FREE Newsletter

User Forms & Controls in VBA

User forms are custom user interface screens that you can develop in VBA to interact with your users. An example user form is shown below.

Example UserForm - Excel VBA

Learn how to use various form controls & user form features in this section.

In this page

What are Form Controls?
Using Excel Form Controls
Different Form Controls & What they do
What are Events
What are Active-X Controls?
Using Form Controls inside Excel Workbooks
VBA User Form Examples
References on Form Controls & User Forms

More on Excel VBA

Excel VBA Homepage
Excel VBA Examples
Video Tutorials on Excel VBA, Macros
Excel VBA Tips
User Forms & Controls in VBA
Books on Excel VBA
References on Excel VBA
Training on Excel VBA
Join our Excel Newsletter

What are Form Controls?

Form Controls are objects which you can place onto an Excel Worksheet or User Forms, which give you the functionality to interact with your data.

You can use these controls to help select data. For example, drop-down boxes, list boxes, spinners, and scroll bars are useful for selecting items from a list. Option Buttons and Check Boxes allow selection of various options. Buttons allow execution of VBA code.

You can place form controls on user forms (created from Visual Basic Editor) or inside Excel worksheets.

By adding form controls to user forms, we can tell Excel how the value entered in that should be treated. This is done a special type of macros called as Events.

By adding a control to a worksheet and linking it to a cell, you can return a numeric value for the current position of the control. You can use that numeric value in conjunction with the Offset, Index or other worksheet functions to return values from lists.

Using Excel Form Controls

You can use form controls in 2 contexts – (1) in User Forms (2) in regular Excel worksheets.

Using Form Controls in User Forms

To use form controls, this is the process we need to follow.

  1. Go to Visual Basic Editor (ALT+F11)
  2. Insert UserForm
  3. Select the UserForm, you should see Toolbox with all userform controls.
  4. If the Toolbox is not displayed, you can enable if from View menu.
  5. Select any userform control and draw it on the userform.
  6. Design the form as per your desire.
  7. Change captions & settings of each control by using Properties window
  8. Tip: You can adjust properties of multiple controls by selecting them all and then making changes to their properties.

Creating your first UserForm – Demo

See this short animated demo to understand how to create & design a UserForm.

Different Form Controls & What they do?

Control Name Description Function
Button Push Button Executes a macro
Check Box Allow selection of non-exclusive options Multiple On/Off options
Combo Box Drop Down selection Box Select items from a Drop down list
Group Box Layout element which groups common elements Nil
Label A Text label Can be static or linked to a cell
List Box Fixed selection box Select items from a list
Option Button Allow selection of exclusive options Exclusive Single On/Off option
Scroll bar Allow Horizontal or Vertical scrolling Increases or decreases a value by a fixed amount. Can be linked to a cell.
Spin Button Increment/decrement a value by a fixed amount Increases or decreases a value in steps by a fixed amount. Can be linked to a cell.

For more information, read Form Controls & how to use them in the context of Excel.

What are Events?

Events are a special type of Macros (VBA instructions) that run whenever user interacts with userform controls. For example, you can write an event to tell Excel what to do whenever user clicks on the submit button. Each userform controls supports various events.

What are Active-x Controls?

Active X controls are like Form Controls on Steroids in that they have a much wider range of properties than Form Controls.

They also have much better ties to VBA in terms of programmability and have a number of events that can be accessed programmatically.

The main limitation of Active X controls are that they use a Microsoft Active X component. This means that if you are sharing your workbook with an Apple Mac user using Excel for Mac  these functions wont be available as Active X isn’t available on that Platform.

Workbooks with Form Controls will happily work on a an Apple Mac.

Using Form Controls inside Excel Workbook

Using Form controls inside Excel is a great way to add interactivity to your workbooks. Below you can see one such example.

Excel Dynamic Chart made with Form Controls

We, at Chandoo.org have lots of examples & detailed tutorials on these. Please visit these pages for more information on this.

VBA User Form Examples

Please check back again. We are adding new examples to this area.

References on Excel VBA UserForms & Controls

Please read thru these references to learn more about UserForms & Form Controls in Excel VBA.

^ Go to Top Excel VBA Examples Videos VBA Tips User Forms & Controls Books References Training FREE Newsletter
Excel VBA - Tutorials, Examples, Information & Resources