Excel VBA ActiveX Controls
Excel VBA ActiveX Controls
ActiveX controls like Command buttons, combo box, list box, text box etc. are the programming controls developed to capture and manipulate data-centric operations.
Just like any other Visual Programming Language, MS Excel VBA also supports ActiveX Controls.
To create an ActiveX control in MS Excel VBA, follow the steps below.
1. On the Developer tab, click Insert.
2. Under the ActiveX Controls group, click Command Button.
3. Drag or draw a command button on your worksheet.
4. Right click the command button (ensure that Design Mode is selected).
5. Click View Code and the Visual Basic Editor appears.
Note: you can change the caption and name of a control by opening its Properties. Change the caption of the command button to ‘Apply Green Text Color’. In this tutorial, you will observe that the default properties of Command Button are being used.
6. Add the following line of code shown in the figure below between Private Sub CommandButton1_Click() and End Sub.
7. Select the range A1:A4 on your worksheet and click the command button (ensure that Design Mode is not selected).
Result: