How to Make a Macro Button in Excel

If you just need to make a macro button in excel and move on, the boxed answer at the top is all you need. The rest of this page is for when you want to understand why it works in Excel, adapt it to a trickier version, or make it robust enough to hand to a colleague. We keep the opening short on purpose — the depth is here when you want it, not in your way when you don’t.

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. The same idea underpins a lot of everyday Excel work, so the few minutes spent getting it right here pay back across every sheet you build afterwards. Treat it as a pattern, not a one-off, and it stops being something you look up and starts being something you reach for. For “make a macro button in excel”, the reliable version is a short checking loop, not just the first command that appears to work. Run it on a deliberately small range first, watch how the affected cells change, and only then apply the same setup to the full sheet. 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 is what makes a workflow that saves repeating the same clicks every week useful in real work: repeatable, auditable, and not dependent on memory or luck.

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

Google Sheets handles this almost identically to Excel. The formula syntax above is the same, and the menu lives under a slightly different label rather than a ribbon tab. Use the platform toggle at the top of the page to switch every keyboard shortcut between Windows and Mac, and expect at most cosmetic differences in naming. The aim was to get you unstuck fast and leave you a little more capable than a copy-paste would. The answer is at the top, the tool proves it, and the detail above shows why it holds — so the next time a colleague asks, you can answer without reaching for search. The short version of “make a macro button in excel”: the answer is at the top of this page, the tool proves it on your own numbers, and the sections above explain why it holds so the next variation does not stump you. Excel rewards people who reference cells instead of typing values and who keep inputs separate from formulas, because that is what makes a result you can audit months later. Build it once, deliberately, with the live tool as a check, and you convert a one-off lookup into a reusable skill — which is the whole point of learning the why and not just the what.

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.