Assign a macro to a button

This tutorial shows how to assign a macro to a Form Control and ActiveX Control button using Excel or VBA


METHOD 1. Assign a macro to a Form Control button

EXCEL

Right-click in a button > Select Assign Macro > Select a macro > Click OK

1. Right-click on the Form Control button.
2. Select Assign Macro.
Right-click on Form Control button and select Assign Macro

3. Select the macro that you want to assign to the button.
4. Click OK.
Select macro and click OK

METHOD 1. Assign a macro to an ActiveX Control button

VBA

Private Sub CommandButton1_Click()
'assign a macro to a button
Application.Run ("Marco1")

End Sub

ADJUSTABLE PARAMETERS
Macro: Select the macro that you want to assign to a button by changing the macro name from ("Macro1") to any existing macro in the workbook.
ADDITIONAL NOTES
Note 1: To quickly enter into the VBA editor that is associate with the button, double click on the button to which you want to assign a macro.

Explanation about how to assign a macro to a button

EXPLANATION

EXPLANATION

This tutorial shows how to assign a macro to a Form Control and ActiveX Control button.
To assign a macro to a Form Control button this can be achieved through an Assign Macro dialog box, therefore, no need to write any additional code to link to a button.
To assign a macro to an ActiveX Control button you will need to use an 'Application.Run("Macro_Name")' VBA code.

RELATED TOPICS

Related Topic Description Related Topic and Description
How to create a message box