ActiveX Control in Excel VBA
Last Updated :
29 Oct, 2022
When we are automating an excel sheet with VBA at that time when the user has a requirement for a more flexible design then it’s better to use ActiveX Controller. In Excel user has to add the ActiveX Controller manually and ActiveX Controls are used as objects in codes. There are the following types of ActiveX Controls that are important:
- Text Box
- List Box
- Combo Box
- Check Box
How to Create ActiveX Control in Excel VBA?
To do some changes in the excel sheet using ActiveX control we need to use the Command-click button for that we have to follow further steps
Step 1: Select the developer tab and click Insert drop-down list from the control box.
Step 2: Choose the command button from ActiveX Controls Box.
Step 3: Draw the command button in the excel sheet.
Step 4: Right-click on the command button and select view code to write the VBA code.
Step 5: When the user will click on Command Button they should get their respective values in the cell. So for that, we have to write codes in VBA.
In the VBA code, we can write codes in different ways to get the action done by VBA on clicking the command button which we have discussed in the following
Text Box
It is a type of ActiveX Controls which is used to fill the empty field with text which is useful for us to get the details of the input from the user such as name, year, department, date of birth, etc by the text of the box
Step 1: Select the Text Box from the ActiveX Controls box.
Step 2: Draw the Text Box in the excel sheet and then right-click on the box to select view code.
Step 3: Write a code in VBA to create a Text Box with a name so that it can be used to access the inputs given by a user.
List Box
It helps us to fill a box with a list of values so that we can users can select any value from it for that we have to follow further steps.
Step 1: Select the List Box from the ActiveX Controls box.
Step 2: Draw the List Box in the excel sheet and then right-click on the box to select view code.
Step 3: Write a code in VBA to add items to the list box.
Combo Box
It is used to make a drop-down list where the user can select an item from the drop-down list for that we have to follow further steps.
Step 1: Select the Combo Box from the ActiveX Controls box.
Step 2: Draw the Combo Box in the excel sheet and then right-click on the box to select the view code.
Step 3: Write a code in VBA to add items to the combo box.
Check Box
It is used to create a check box where a list of values is stored which gets visible upon selecting the check box for that we have to follow further steps.
Step 1: Select the Check Box from the ActiveX Controls box.
Step 2: Draw the Check Box in the excel sheet and then right-click on the box to select view code.
Step 3: Write a code to display the value when a check box is marked.

Similar Reads
VBA Collections in Excel
An object that can store a number of values whether it can be of string data type or integer which can be easily manipulated or iterated is called Collection. In Excel VBA we should declare it as a new collection. It is an unchangeable, one-dimensional entity, unaffected by size adjustments. This im
6 min read
VBA Constants in Excel
There can be situations when you want to declare a number in your program that you never want to be changed. In other situations, like, as if you have used a person's name many times in your program and you want to change that name, this assigned task could be hectic if you change the name of that p
6 min read
Excel VBA Events
An action performed by VBA code is called an event. Suppose, some events are executed automatically by Excel that's because of the code written in VBA which is known as Event Handler. The execution of a specified macro can be triggered using an action which is known as an event. For example, if we w
3 min read
Excel VBA | count() functions
Visual Basic for Applications (VBA) is the programming language of Excel and other offices. It is an event-driven programming language from Microsoft. With Excel VBA one can automate many tasks in excel and all other office software. It helps in generating reports, preparing various charts, graphs a
2 min read
VBA Arrays in Excel
Arrays are used to store data of similar data types. Suppose there are 300 students rather than declaring 300 variables for students, we can declare one array where we can store 300 elements. In this article, we will learn about excel VBA arrays. Declaration of Array Declaring an array is similar to
5 min read
Application Objects in Excel VBA
The Excel VBA Application object is one of the most commonly utilized objects when using VBA to automate any task. It uses several Excel programs and runs various operations on Excel Workbooks. To work with the Excel Application Object, it has many Properties and Methods. Below is a brief descriptio
2 min read
Debugging VBA Code in Excel
When we use VBA to write code in excel or when we any programming language to write code we may encounter errors that need to be analyzed, checked, and fixed. To overcome this problem most IDEs and programming languages support debugging. Debugging is the process of executing your programming codes
5 min read
Excel VBA | Average() Functions
VBA (Visual Basic for Applications) is the programming language of Excel and other offices. It is an event-driven programming language from Microsoft. With Excel VBA, one can automate many tasks in excel and all other office softwares. It helps in generating reports, preparing various charts, graphs
2 min read
Editing Excel Macros in Excel
Excel Macro is a set of actions that can be recorded, saved, used multiple times. This feature saves us a lot of time when dealing with repetitive tasks and huge data sets. We can always make changes to an existing Macro in Excel. There are two ways to record and run macros: Excel Commands Excel Vis
1 min read
What is a Cell in Excel?
MS-EXCELÂ is a part of Microsoft Office suite software. It is an electronic spreadsheet with multiple rows and columns, used for organizing data and performing different calculations. A spreadsheet takes the shape of a table, consisting of rows and columns. A cell is created at the intersection point
5 min read