This tutorial will demonstrate how to use ActiveX control in excel. ActiveX control is a more flexible design than any of the Form controls. Using ActiveX controls such as the command button, text boxes, list boxes, etc. can ease your work a lot. So, it is very important to learn how to use ActiveX control in excel.
If you follow the steps correctly, you should learn how to use ActiveX control in excel on your own. The steps are:
Step 1: Preparing Dataset
In this case, our goal is to use ActiveX control by arranging a dataset. We have arranged a dataset in which we have the Input in column B.We’ll use a sample dataset overview as an example in Excel to understand easily.
Read More: How to Use VBA Input Function in Excel (2 Examples)
Step 2: Inserting Command from Excel ActiveX Controls
Now, we aim to use ActiveX control by inserting the command button option. The description of this step is.
- At first, go to Developer > Insert > ActiveX Controls options.
- Then, select the cell range and insert the CommandButton1Â option.
Step 3: Applying VBA Macro Code
Then, we will connect the button with a proper VBA code to function accordingly. The process of this step is.
- Firstly, right-click on the button and select the View Code option.
- Secondly, the VBA window will come on the screen. Then, select the Module option from the Insert tab and insert the following code in the window.
Private Sub CommandButton1_Click()
   MsgBox "Hi Friend!, it's " & Time
End Sub
- Lastly, press the Run option and then if you click on the button, you will get the desired result.
Similar Readings
- 22 Macro Examples in Excel VBA
- How Different Is VBA from Other Programming Languages
- Learn Excel VBA Programming & Macros (Free Tutorial – Step by Step)
- List of 10 Mostly Used Excel VBA Objects (Attributes & Examples)
- 20 Practical Coding Tips to Master Excel VBA
How to Fix If Excel ActiveX Control Is Not Working
Suppose, you have followed the above steps correctly but still the button is not working then you have to enable the ActiveX controls to fix it. The steps to do so are.
Steps:
- First, go to the File option.
- Second, click on the Info option and select the Turn Center Settings options.
- Third, in the Trust Center dialog box, go to Trusted Documents > Allow Documents on a network to be trusted > OKÂ options.
- Last, if it still doesn’t work, then in the Trust Center dialog box, go to ActiveX Settings > Enable all controls with restrictions > OK options.
- Therefore, you will see that your problem is already fixed.
How to Remove Activex Control in Excel
In this case, our goal is to remove the ActiveX control in excel by following the below process.
Steps:
- At first, select the ActiveX control button.
- Next, go to the Developer tab.
- Then, select the Design Mode to turn off the design mode.
- Last, if you click on the ActiveX control button, you won’t see it working or any desired result.
Things to Remember
- We have shown the steps of using the ActiveX control in excel. But before using it, you have to enable the ActiveX control settings at the beginning. Otherwise, it won’t work.
- For using VBA code, the files must be saved as Excel-Macro Enabled Workbook. Otherwise, codes won’t work.
Download Practice Workbook
You can download the practice workbook from here.
Conclusion
Henceforth, follow the above-described methods. Hopefully, these methods will help you to use ActiveX control in excel. We will be glad to know if you can execute the task in any other way. Follow the ExcelDemy website for more articles like this. Please feel free to add comments, suggestions, or questions in the section below if you have any confusion or face any problems. We will try our best to solve the problem or work with your suggestions.
Related Articles
- How to Write VBA Code in Excel (With Easy Steps)
- Types of VBA Macros in Excel (A Quick Guide)
- What You Can Do with VBA (6 Practical Uses)
- Introduction to VBA Features and Applications
- How to Make VBA Code Run Faster (15 Suitable Ways)
- 6 Best Excel VBA Programming Books (For Beginners & Advanced Users)