ActiveX controls offer more flexibility than Form controls. By using ActiveX controls such as command buttons, text boxes, and list boxes, you can streamline your work in Excel.
Let’s learn how to use ActiveX controls step by step:
Step 1 – Preparing the Dataset
Our goal is to use ActiveX controls with a dataset. Assume we have arranged data in column B. We’ll use a sample dataset overview in Excel for easy understanding.
Read More: How to Use VBA Input Function in Excel
Step 2 – Inserting a Command Button from Excel ActiveX Controls
- Go to the Developer tab.
- Click Insert and select ActiveX Controls.
- Choose the cell range where you want to insert the CommandButton1.
- Insert the CommandButton1 option.
Step 3 – Applying VBA Macro Code
- Right-click on the button and select View Code.
- In the VBA window, choose Module from the Insert tab.
- Insert the following code:
Private Sub CommandButton1_Click()
MsgBox "Hi Friend!, it's " & Time
End Sub
- Press Run. Clicking the button will give you the desired result.
How to Fix If Excel ActiveX Control Is Not Working
If the button isn’t working despite following the steps correctly, enable ActiveX controls:
- Go to the File option.
- Click Info and select Trust Center Settings.
- In the Trust Center dialog box, go to Trusted Documents, select Allow Documents on a network to be trusted and click OK.
- If it still doesn’t work, go to ActiveX Settings, select Enable all controls with restrictions and click OK.
How to Remove ActiveX Control in Excel
- Select the ActiveX control button.
- Go to the Developer tab.
- Turn off Design Mode.
- Clicking the ActiveX control button won’t produce any result.
Things to Remember
- Enable ActiveX control settings before using them.
- Save files as Excel-Macro Enabled Workbook to use VBA code effectively.
Download Practice Workbook
You can download the practice workbook from here:
Related Articles
- How to Write VBA Code in Excel
- Types of VBA Macros in Excel
- What You Can Do with VBA
- Introduction to VBA Features and Applications
- How to Make VBA Code Run Faster
- 6 Best Excel VBA Programming Books