ActiveX - Button
The ActiveX Command Button can be placed onto a worksheet.
Display the "Developer" tab, Controls group and select from the Insert drop-down.
Draw the control onto the worksheet.
When an ActiveX control is added to a worksheet it is actually embedded and becomes an Object of the worksheet.
Unlike the Button from the Form Controls there is no quick way to assign a macro.
Shortcut Menu
When you right mouse click on this control the following shortcut menu will be displayed.
Properties - Displays the floating "Properties" window from the VBE Editor.
View Code - Opens the Visual Basic Editor application window.
Format Control - Displays the "Format Control" dialog box.
Assigning a Macro
To assign a macro to this button you need to use the Visual Basic Editor.
Right mouse click on the button and select "View Code".
This will open the VBA Editor window and insert the following lines of code.
Private Sub CommandButton1_Click()
End Sub
Notice that this code appears in the worksheet code module that corresponds to the worksheet that contains the button.
If you have recorded your macro you need to call the corresponding subroutine from here.
Private Sub CommandButton1_Click()
Call Macro1
End Sub
Design Mode
Every time you insert an ActiveX control onto a worksheet, you will be automatically placed in Design Mode.
Before you can actually run your macro using the button you need to exit "Design Mode".
Switching to design mode makes moving and resizing the ActiveX controls easier.
Format Control
The Format Control dialog box is the same for all the ActiveX controls.
SS
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext