ActiveX Controls in Excel VBA
Learn the basics of using ActiveX controls like buttons, text boxes, and list boxes in Excel. Follow these steps to insert an ActiveX control in Excel and use VBA to program its behaviour and functionality.
1. On the Developer tab, click Insert.
2. From ActiveX Controls, select Command Button.
3. Place a command button on your worksheet by dragging it from the toolbox.
4. Ensure Design Mode is enabled so you can right-click the command button to edit its properties or settings.
5. Click View Code.
Note: Right-click the control in Design Mode, choose Properties, then edit the Caption and Name fields to change them. Change the button’s caption to “Apply Blue Text Color”. For now, keep the default name, “CommandButton1”.
The Visual Basic Editor appears.
6. Add the code inside the CommandButton1_Click subroutine, before the End Sub line.
7. First, choose the cell range B2 to B4. Then, click the command button. Design Mode must be turned off to allow the command button to work properly when interacting with worksheet cells.
Result:
1/8 Completed! Learn more about ActiveX controls ➝
Next Chapter: Userform