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 SubButtons.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
- Press Alt + F11 to open the VBA editor.
- Insert > Module.
- Paste the code above.
- Press
F5, or close the editor and run it from Developer > Macros. - Save the file as .xlsm so the macro is kept.
Turn on the Developer tab if it is not visible: File ▸ Options ▸ Customize Ribbon, tick Developer, click OK.
Choose Developer ▸ Insert and pick Button under Form Controls — the top-left icon, not the ActiveX section below it.
Drag out a rectangle where you want the button to sit; the Assign Macro dialog opens automatically.
Select the macro name and click OK.
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.
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. Most people learn this as a sequence of clicks and forget it by next week; learning it as a pattern instead is what lets you apply it to the next, slightly different version of the problem without starting from scratch. That is the difference this page is trying to make. For “insert 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. One habit worth forming early: name the cells that hold your inputs, so the formula reads in plain language instead of a string of cell addresses. A reviewer — or you in three months — can then follow the logic without decoding what B7 and D2 were supposed to mean, which is most of what makes a sheet maintainable.
In Google Sheets
Everything above works in Google Sheets too. Excel and Sheets share the formula syntax used here; only the surrounding menus are arranged differently. That portability is deliberate — learn it once and it follows you between the two tools and across Windows and Mac. 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. Treat “insert macro button in excel” as a small building block rather than a chore. Once the inputs sit in their own cells and the formula reads from them, the same setup answers a dozen related questions with a tweak, and Excel keeps every dependent figure current as the data changes. The tool above is there so you can rehearse and verify before committing anything to a real workbook; the steps and worked example are there so the logic sticks. Get it right once and it stops costing you time — it starts saving it, every time the question comes back around.
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 “excel insert macro button” and “insert a macro button in excel”. They describe the identical operation, so you are in the right place no matter how you phrased it.
Why do people search for this in so many different ways?
Because the same task has many names. “excel insert macro button”, “insert a macro button in excel” all point at the one operation explained on this page, which is why they all lead here.