ActiveX Control in Excel VBA

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.