How to Create a Macro Button in Excel

There are two ways to “create a macro button in excel”: the quick way you copy and the durable way you understand. This page gives you both. The exact Excel answer is above; below, we build the small mental model that makes the fix stick, so the next variation of the same problem solves itself.

Exact answer

In Excel: Developer ▸ Insert ▸ Button (Form Control), drag out the rectangle on the sheet, and pick your macro from the Assign Macro dialog that opens.

VBA macro: Add a Button That Runs a Macro

Sub AddMacroButton()
    Dim ws As Worksheet
    Dim btn As Button
    Set ws = ActiveSheet
    Set btn = ws.Buttons.Add(ws.Range("F2").Left, ws.Range("F2").Top, 130, 28)
    btn.OnAction = "SayHello"
    btn.Caption = "Run SayHello"
End Sub

Sub SayHello()
    MsgBox "The button ran this macro.", vbInformation
End Sub

Buttons.Add takes Left, Top, Width and Height in points, so anchoring to a cell's .Left/.Top drops the button neatly over F2. OnAction holds the macro NAME as text — a typo there fails silently at click time, not at compile time.

How to run this macro

  1. Press Alt + F11 to open the VBA editor.
  2. Insert > Module.
  3. Paste the code above.
  4. Press F5, or close the editor and run it from Developer > Macros.
  5. Save the file as .xlsm so the macro is kept.
Annotated stepsExcel
1

Turn on the Developer tab if it is not visible: File ▸ Options ▸ Customize Ribbon, tick Developer, click OK.

2

Choose Developer ▸ Insert and pick Button under Form Controls — the top-left icon, not the ActiveX section below it.

3

Drag out a rectangle where you want the button to sit; the Assign Macro dialog opens automatically.

4

Select the macro name and click OK.

5

Right-click the button and choose Edit Text to relabel it — never left-click, which runs the macro — then click any cell to leave edit mode and test it.

Ctrl+CthenCtrl+Shift+V+Cthen+Ctrl+VPaste values · WindowsMac

What this does

A button is the difference between a macro only its author can run and one the whole team can. Excel offers three ways to place one. The Form Control button is the right default: Developer ▸ Insert ▸ Button, drag a rectangle, and Excel immediately opens Assign Macro so you can pick the procedure. It is lightweight, survives being copied between workbooks, and works on Mac. The ActiveX command button in the same menu looks more configurable but is Windows-only and notorious for corrupting itself, so avoid it unless you need a property the Form Control lacks. The third option skips controls entirely: draw any shape via Insert ▸ Shapes, right-click it, and choose Assign Macro — you get a button that can look like anything, which is how most polished dashboards do it. Keep the inputs visible and clearly labelled and the whole thing stays auditable — anyone who opens the file later, including you, can see at a glance exactly what feeds the result and change one assumption without hunting through the formula. Treat “create a macro button in excel” as a small repeatable workflow rather than a one-off click you hope to remember next time. Use a small test block before the live file, so any surprise in the affected cells shows up while it is still harmless. When this is a ribbon command, the selection matters more than the button: confirm the range, apply the command, then spot-check the output before saving. That turns a workflow that saves repeating the same clicks every week into a method you can reuse, explain, and defend when the workbook leaves your screen.

A worked example

Your workbook has a macro named RefreshReport and colleagues keep asking where to find it. Open the Developer tab (File ▸ Options ▸ Customize Ribbon ▸ tick Developer if it is missing), choose Insert ▸ Button under Form Controls, and drag a rectangle beside the data. The Assign Macro dialog opens; select RefreshReport and click OK. To relabel it, right-click the button and choose Edit Text — a left-click just runs the macro, so right-click is the instruction that works whether or not the control still happens to be selected. Now anyone can run the macro without ever opening the editor. To do the same in code rather than by hand, run Sub AddMacroButton() — it places a button over F2 and points its OnAction at SayHello, which is useful when a macro has to build its own interface across many sheets. A macro nobody can find is a macro nobody uses. Putting a labelled button on the sheet removes the Alt + F11 barrier entirely, which is what makes an automation shareable with people who will never open the editor. A practical tip before you scale it up: build it once on a small block of test data, confirm the number against the tool on this page, and only then point it at your real sheet. That one habit catches almost every mistake while it is still cheap to fix, long before a wrong figure reaches a report or a colleague.

In Google Sheets

If you are in Google Sheets rather than Excel, the good news is that the formula shown here is identical and the workflow barely changes — menus sit across the top instead of in a ribbon, and a few function names differ slightly, but anything you build here moves across with little or no rework. Nothing on this page is behind a login: the tool runs entirely in your browser, the formula is shown in full with one-click copy, and the steps work the same on Windows and Mac. That is the whole promise here — the exact answer, a way to prove it on your own numbers, and just enough context to make it stick. Here is the takeaway for “create a macro button in excel”: copy the answer if you are busy, but if you have a spare few minutes, rebuild the example in Excel yourself with the tool above open beside it. That single pass — type it, run it, watch the result move when you change an input — is what turns a formula you found into a technique you trust. Keep your inputs labelled and referenced, never hard-coded, and the same sheet stays correct and auditable as it grows. Done that way, you will not need to look this up again, and you will be the person others ask.

Common mistakes

  • Picking the ActiveX command button instead of the Form Control. ActiveX controls are Windows-only, break on Mac, and are a well-known source of "Cannot insert object" corruption after the file has moved between machines.
  • Left-clicking the finished button to move or edit it, which just runs the macro. Right-click (or Ctrl + click on Mac) selects it for editing instead.
  • Assuming a button carries its macro with it. Copying a button into another workbook copies only the macro NAME held in OnAction; if no procedure of that name exists there, the click fails with "cannot be found".
  • Letting the button float over data. Right-click ▸ Format Control ▸ Properties ▸ "Don't move or size with cells" keeps it in place when rows are inserted or columns resized.

Frequently asked questions

How do I edit a button without triggering the macro?

Right-click it (Ctrl + click on Mac). That selects the control and opens the context menu with Edit Text, Assign Macro and Format Control, without running anything.

Can I use a picture or a shape instead of a grey button?

Yes, and most dashboards do. Insert ▸ Shapes or Insert ▸ Pictures, then right-click the object and choose Assign Macro. It behaves exactly like a Form Control button.

My button says the macro cannot be found — why?

OnAction stores the macro name as plain text, so renaming the Sub, deleting its module, or copying the button to a workbook without that procedure all break the link. Right-click ▸ Assign Macro and re-select it.

Can one button run several macros?

Indirectly. Point the button at a single wrapper Sub that calls the others in order — that also makes the sequence easy to change later without touching the button.

Other ways people ask this

This is also commonly searched as “create a macro button in excel”, “create macro button in excel”, “how do you create a macro button in excel” and “how to create macro button excel”. They describe the identical operation, so you are in the right place no matter how you phrased it.

This guide also answers

  • excel add macro button
  • how to insert macro button in excel
  • how to make a macro button in excel

Why do people search for this in so many different ways?

Because the same task has many names. “create a macro button in excel”, “create macro button in excel”, “how do you create a macro button in excel” all point at the one operation explained on this page, which is why they all lead here.