How to Add a Button That Runs a Macro in Excel

To add a button that runs a macro in Excel, go to the Developer tab, click Insert, and choose the Button under Form Controls (the top group, not ActiveX). Draw it on the sheet and Excel immediately asks which macro to assign. Pick one and click OK. The button runs that macro on a single click from then on.

Use Form Controls rather than ActiveX unless you have a specific reason not to. Form Controls are simpler and they work in Excel for Mac, which ActiveX does not.

Adding the button

1 On the Developer tab, click Insert. If the tab is missing, enable it under File, Options, Customize Ribbon.

2 Under Form Controls, click the first icon, Button.

3 Drag on the sheet to draw it. The Assign Macro dialog opens by itself.

4 Select your macro and click OK.

5 The button text is editable: right-click it and choose Edit Text. Name it for what it does, such as “Refresh Report”, not “Button 1”.

Right-click selects, left-click runs

Once a button is assigned, left-clicking runs the macro. To move, resize, rename or reassign it, right-click it instead. This trips people up constantly: they try to drag the button and run the macro by accident.

Using a shape instead, which usually looks better

Form Control buttons look dated. Any shape can run a macro and you get full control over its appearance:

1 Insert → Shapes and draw a rounded rectangle.

2 Format and add text to it however you like.

3 Right-click the shape and choose Assign Macro.

4 Pick the macro and click OK.

It behaves identically to a Form Control button and looks like part of the design rather than a control bolted on top. Shapes are typically the better choice wherever appearance matters.

Form Controls compared with ActiveX

The Insert menu on Windows shows two groups, and the difference matters more than it looks.

Form Controls are simple, stable, and work on both Windows and Mac. They run one assigned macro. For running a macro from a sheet, this is what you want.

ActiveX Controls offer more design properties and their own events, such as reacting when the mouse moves over them. They are also a Windows-only technology: Excel for Mac has no ActiveX at all, so a workbook using them is broken for every Mac user. They have a long reputation for corrupting and for resizing themselves unpredictably between screen resolutions.

Choosing ActiveX makes the file Windows-only

If there is any chance the workbook will be opened on a Mac, use Form Controls or shapes. This is one of the differences covered in does Excel VBA work on Mac.

Common questions

My button does nothing when I click it

Almost always macro security rather than the button. If the workbook came from the internet or email, macros are disabled and nothing on the sheet will respond. See how to enable macros in Excel, and if you are unsure whether you should, is it safe to enable macros.

How do I change which macro a button runs?

Right-click the button and choose Assign Macro, then pick a different one. The button keeps its text, so remember to update that too or it will lie about what it does.

Can a button run a macro stored in another workbook?

Yes, if that workbook is open. Type the full reference into the Assign Macro box, in the form 'Other File.xlsm'!MacroName. If the file is closed the button fails, which is why macros meant to be available everywhere usually live in the Personal Macro Workbook.

How do I stop the button moving when rows are resized?

Right-click it, choose Format Control, then on the Properties tab select Don’t move or size with cells. Without this, inserting rows above the button drags it down the sheet.

Can I make a keyboard shortcut instead?

Yes. Developer → Macros, select the macro, click Options and assign a letter. Be careful: it will override the built-in Excel shortcut for that combination while the workbook is open, so Ctrl+S is a poor choice.

When Formulas Aren’t Enough

A button is where a spreadsheet starts becoming an application:

  • One-click processes — import, clean, validate and export without the user knowing the steps
  • Guarded actions — confirmation prompts before anything is overwritten or deleted
  • A real interface — forms and menus instead of instructions on a hidden tab

A custom VBA tool gives the people using it buttons rather than a procedure to remember.

Want a Spreadsheet Anyone Can Use?

Tell us what the process is and we’ll build the interface around it.

Start a Project

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top