Forms and Controls in Excel VBA

Home/Excel VBA/Forms and Controls in Excel VBA

Any Windows Application is equipped with set of objects called windows controls. Forms and Controls in Excel VBA topics give you the complete understanding of developing application with Forms and Controls.
In This Section:



50+ Project Management Templates Pack
Excel PowerPoint Word

Advanced Project Plan & Portfolio Template
Excel Template

Business Presentations Templates Pack
PowerPoint Slides

20+ Excel Project Management Pack
Excel Templates

20+ PowerPoint Project Management Pack
PowerPoint Templates

10+ MS Word Project Management Pack
Word Templates

What Are UserForms?

Any Windows Application is equipped with set of objects called windows controls. The Main control is called a Form, it is the primary window contains different types of controls which allow user to interact with the computer. The following is a simple form to calculate square value of a given number.

Example UserForm

You can enter the any numerical value in TextBox and Push the Command Button to see the result (Example file is attached in this post).

What Are UserForm Controls or ActiveX Controls?

UserForm Controls are objects which you can be placed onto UserForms to interact with your data. There are several ActiveX controls which help users to do different activities with data, each control have different functionality.

We can place form controls on user forms based on our requirement, then add the code for each control to perform required tasks. Following are most commonly used control and their uses.

What Are The Different UserForm Controls & Use?

You can click on the ToolBox to see the various controls available in the VBE (Visual Basic Environment).


Control Control Name Description
userform-ToolBar1 Label You can use this contol to display the text on the userform
userform-ToolBar2 Text box Enable user to enter some text or data
userform-ToolBar8 Command button Push Button, uses to runs a macro that performs an action when a user clicks it
userform-ToolBar3 Combo Box Drop-down list can be used to provide the interface to select one item from the list of items
userform-ToolBar4 List Box List Box can be used to provide the interface to select one or more item from the list of items
userform-ToolBar8 Frame Layout element which groups common elements
userform-ToolBar6 Option Button Allow user to select an exclusive option from the list of choices
userform-ToolBar5 Check Box Allow user to select one ore more options from the list of choices
userform-ToolBar15 Image You can use this to display a image on the userform

You can add more control to the toolbox dialog by right clicking on the toolbox dialog.


Forms and Controls in Excel VBA – Practical Learning: Developing A Simple UserForm

Now we will develop a simple userform, follow the below steps to create a userform to Find Square Values of a given number.

Step 1: Open VBE by pressing Alt+F11


Step 2: Goto Menu Bar -> Insert -> Click on UserForm


It should look like this:

Step 3: Click On ToolBox and Add Three Labels, One TextBox and Two Command Buttons as shown below



Step 4: Now Click On the First Label and Change the Caption of the Label as “Enter a Value” – as shown below


Similarly, change the caption of second Label as “Square Value”, Caption of the Third Label as blank(just delete the captions, we need this blank label to show the square value of the given value), Command Button1 as “Find Square Value”, Command Button2 as “Exit”, it should look like this:

Step 5: Now Double Click On the First Command Button (Find Suare Value), It will take you to the form code module, place the following code
Private Sub CommandButton1_Click()
'Calculate Square Value
Label3.Caption = TextBox1.Value * TextBox1.Value
End Sub

Similarly add the following code for Exit Button:

Private Sub CommandButton2_Click()
'Exit Form
Unload Me
End Sub

Now- your code module should look like this:

Step 6: Click on the Useform (left pane) to view the designed Form and Click on the Run Button to test it



Step 7:You can insert an ActiveX Command Button in the Worksheet and Add the following code to call the userform from your Worksheet
Private Sub CommandButton1_Click()
'Call userform
End Sub

Example File

userform-pl11 – Simple UserForms

By |May 25th, 2013|Excel VBA|6 Comments

About the Author:

PNRao is a passionate business analyst and having close to 10 years of experience in Data Mining, Data Analysis and Application Development. This blog is his passion to learn new skills and share his knowledge to make you expertise in Data Analysis (Excel, VBA, SQL, SAS, Statistical Methods, Market Research Methodologies and Data Analysis Techniques).


  1. Ali February 23, 2015 at 10:21 AM - Reply

    Hi sir, loved your website! The only thing I would like to point out is that you’ve interchanged the icons for Command buttons and Frame in your indroduction. Might get confusing for newbies!

    Thanks and keep up the good work!

    • PNRao March 2, 2015 at 7:44 PM - Reply

      Thanks lot Ali- Changed now! PNRao!

  2. Tracey-lee March 5, 2015 at 11:35 PM - Reply

    Thank you soooo much for all the information that you have shared as well as the time. I am a newbie and really appreciate your site.

  3. Naresh August 31, 2015 at 8:38 PM - Reply

    Thank u very much sir…i’m new for this website but i noticed that u care of our request or comments…so once again thank u…

    • PNRao August 31, 2015 at 11:06 PM - Reply

      You are most welcome Naresh! I am glad you found this useful.

  4. November 19, 2015 at 9:10 PM - Reply

    Thank you verrrry much. most of the time I find what am looking for in your site. God bless you.

Leave A Comment

Related pages

vlookup in excel 2003vba procedureshow to place a tick in excelexcel 2010 unprotect workbookuserform listboxexcel if statement examples textwriting macros in excel 2007how to merge two columns in excelrows vbams excel vlookup formulas examplessql developer interview questions and answers pdfvba excel outlookmicros and macros in exceldml in databasemultiple columns in excelexample of vlookup in excelsas code tutorialremove characters excelfilesystemobject vbaexcel vba array of stringscombobox in excel vbahlookup formulaexcel char functionmacro remove duplicateshow to create a hyperlink in excelsum function in vbaexcel loop macroexcel dynamic chartsvba array tutorialmacros programming in excelselect range in excel vbaexcel vba chart objectasap utilities 64 bit downloadvlookups tutorialexcel test for beginnersactivesheet.namevba dim asvba excel outlookiferror with vlookupcopy cells vbaopen excel file in vbaexcel macro enablecase statement in excel formulaexcel macro tablevba import excel into access tablefind duplicates in excelvba codedelete empty cells in excelexcel forms vbaif isnumeric vbatest vba codevba offset rowhow to unhide column a in excel 2013how to write macros in excel 2007excel vba sampleexcel macro writingusing hlookup in excelshortcut keys excelremove unused cells in excelexcel formula correctorlocking formulas in excel 2010qtp existexport data from access to excel using vbanested if else in excelexcel remove non duplicatesvba stopexcel vba usesvba excel templatevba instrexcel vba rows countvba macro basicsfor each vba excelexcel macro write to cellexcel vba open csv filequery sql server from excelexcel metrics dashboardvlookup explained simplycopy values vbamerge and centre in excelms excel consolidateconvert excel rows to columns