How to Create a Macro Button in Excel – 3 Methods

This is the sample dataset.

How to Create a Macro Button in Excel

Use this code to assign to macro buttons that will return the row numbers in the active sheet.

How to Create a Macro Button in Excel


Method 1 – Using the Control Button to Create a Macro Button

1.1. Using Form Control Button

Steps:

  • Go to: Developer > Insert > Form Controls > Button.

Choosing Form Control Button to Create a Macro Button

Your cursor will display a plus sign.

Set Size to Create a Macro Button

  • Left-click and hold; drag the cursor to place the button.

Rectangle Macro Button

  • In the Assign Macro dialog box, select the Macro name.
  • Click OK.

Select the Macro name to Create a Macro Button

You can change the button name and edit the size of the macro button.

  • Double-click the button and enter the name. Here, Used Rows.

  • Click the button to run the macro and see the output:

 


1.2. Using the ActiveX Control Button

Steps:

  • Go to: Developer > Insert > ActiveX Controls > Button.

Using Control Button to Create a Macro Button

  • Place the button in the sheet and set its size.

Set Size to Create a Macro Button

  • Right-click the button and select View Code.

Insert Code to Create a Macro Button

  • In the VBA window, you will see the Sub and End procedures by default.

  • Copy the codes from the module and paste them.
  • Click the Run icon to activate the codes for the button.

  • Click the button to run the codes.


Method 2 – Inserting Shapes to Create a Macro Button

Steps:

  • Go to Insert and choose a shape in Shapes. Here, Rectangle with Rounded Corners.

Inserting Shapes to Create a Macro Button

  • Set the button size.
  • In Shape Format, you can change the shape style. Here, Blue, Accent 5.

Choose Shape Style for the Macro Button

  • Double-click the button and enter its name.

Set Name for the Macro Button

  • Right-click the button and select Assign Macro.

 

  • Select the macro and click OK.

  • Click the button to run the macro.


Method 3 – Using the Quick Access Toolbar to create a Macro Button

Steps:

Using Quick Access Toolbar to Make a Macro Button

  • Choose Macros in Choose commands from.
  • Select your macro name and click Add>>.

Set Macro Name for the Button

  • Click Modify to change the button symbol.

Modify the Macro Button Icon

The Play icon was selected, here.

  • Click OK.

  • Click the button.

This is the output:


Download Practice Workbook

Download the free Excel workbook.

Get FREE Advanced Excel Exercises with Solutions!
Md. Sourov Hossain Mithun
Md. Sourov Hossain Mithun

Md. Sourov Hossain Mithun, an Excel and VBA Content Developer at Softeko's ExcelDemy project, joined in October 2021. Holding a Naval Architecture & Marine Engineering degree from BUET, Mithun showcases expertise during his two-year tenure. With over 200 published articles on Excel topics, he earned a promotion to Team Leader, excelling in leading diverse teams. Mithun's passion extends to Advanced Excel, Excel VBA, Data Analysis, and Python programming, contributing significantly to the innovative and dynamic environment of ExcelDemy... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo