What a button does in Excel
A button in Excel is a clickable object that runs a set of instructions — called a macro — when you click it. Instead of manually entering data or running the same steps over and over, you click the button and Excel does the work. Buttons are useful when you have a spreadsheet that other people use, or when you repeat the same task many times in the same file.
Excel buttons sit on top of your spreadsheet cells. You can place them anywhere, resize them, and change their label to say whatever you want. When someone clicks the button, it triggers a macro — a recorded sequence of actions or a script you write. The macro might clear old data, copy values from one sheet to another, format cells, or calculate results.
Before you add a button, you need a macro ready to run. If you have never recorded a macro before, that is the first step. The button itself is just the visible trigger that makes the macro run.
Key Takeaways
- A button in Excel is a clickable object that runs a macro — a set of recorded or written instructions — when you click it.
- You must record or write a macro before you can attach it to a button, because the button needs something to do.
- Buttons are inserted from the Developer tab, which you may need to turn on first in Excel settings.
- After you insert a button, you right-click it, choose Assign Macro, and pick the macro you want it to run.
- Once assigned, you can click the button in normal spreadsheet mode and it will run the macro without showing the macro code.
Turn on the Developer tab if you do not see it
The Developer tab is where Excel keeps the button tool. If you do not see a Developer tab at the top of Excel next to Home, Insert, and Page Layout, you need to turn it on. This is a one-time setup.
On Windows: Click File in the top left, then Options at the bottom of the left menu. In the Options window, click Customize Ribbon on the left side. On the right side, you will see a list of tabs with checkboxes. Find Developer in that list and check the box next to it. Click OK. The Developer tab now appears at the top of Excel.
On Mac: Click Excel in the top left menu bar, then Preferences. In the Preferences window, click Ribbon & Toolbar. On the right side under Customize the Ribbon, find Developer in the list and check the box. Click Save. The Developer tab now appears at the top.
Record a macro or write one first
Before you insert a button, you need a macro for it to run. The simplest way to create a macro is to record one — you perform the actions you want to repeat, and Excel writes the code for you. You do not need to know how to code.
To record a macro: Click the Developer tab. On the left side, click Record Macro. A small window appears asking you to name the macro — call it something short and clear, like ClearData or FormatReport. Leave the other settings as they are and click OK. Now perform the exact actions you want the button to repeat — enter data, format cells, delete rows, whatever you need. When you are done, click Developer again and click Stop Recording. The macro is now saved in your file.
If you already have a macro written or recorded, you can skip this step and move straight to inserting the button.
Insert a button on your spreadsheet
With the Developer tab visible, click it. In the Controls section, you will see a button icon labeled Button (Form Control). Click that button icon. Your cursor changes to a crosshair. Click and drag on your spreadsheet to draw the button — the size and location are up to you. When you release the mouse, a small dialog appears asking you to assign a macro.
If the dialog does not appear, or if you want to assign a macro later, right-click the button and select Assign Macro. A window opens showing all the macros in your file. Select the macro you want the button to run and click OK.
The button now shows a default label like Button 1. To change the label, right-click the button and select Edit Text. Type the new label — something like Clear Data or Run Report — and click outside the button when you are done.
Test the button and adjust it
Click somewhere else on the spreadsheet to deselect the button. Now click the button itself. The macro runs. If it does something wrong, you can undo it by pressing Ctrl+Z (or Cmd+Z on Mac), then edit the macro or record a new one.
To edit the macro code itself, click Developer, then click Macros. Select the macro name and click Edit. A code window opens. If you know how to write or modify code, you can change it here. If not, the simplest fix is to delete the macro and record a new one.
To move or resize the button, click it once to select it (you will see small squares around it), then drag it to a new location or drag the corners to resize it. To change the button label again, right-click and select Edit Text.
Protect your spreadsheet so the button stays functional
If you share your spreadsheet with others, you may want to protect it so people cannot accidentally delete the button or change the macro. Click the Developer tab, then click Protect Sheet. A window appears with options. Leave the defaults as they are — the important ones are already checked — and click OK. You can set a password if you want, but it is optional.
When the sheet is protected, people can still click the button and use the spreadsheet normally, but they cannot edit cells that are locked or delete the button. If you need to make changes later, click Developer again and click Unprotect Sheet. If you set a password, you will need to enter it.
Troubleshooting common button problems
If you click the button and nothing happens, the macro may not be assigned to it. Right-click the button and select Assign Macro. Make sure a macro is selected in the list and click OK. If no macros appear in the list, you need to record one first.
If the button is hard to click or keeps getting in the way, you can move it or hide it. Right-click the button and select Cut, then click a cell far to the right or below your data and paste it there. If you want to hide it entirely, you can place it behind a cell with a white background or move it to a hidden row.
If you delete the macro by accident, the button will no longer work. You can delete the button itself by right-clicking it and selecting Delete, or you can record the macro again and reassign it to the button.
Frequently Asked Questions
Can I add a button that opens another file or website?
Yes, but you need to write or record a macro that does it. The easiest way is to record a macro while you manually open the file or website, though this does not always work perfectly. For more control, you can write a macro using VBA code. Search your version of Excel for "VBA hyperlink" or "VBA shell command" to find examples.
What if I want the button to do different things depending on what data is in the spreadsheet?
You need to write a macro with conditional logic — code that checks a condition and runs different actions based on the result. This requires writing VBA code, not just recording. If you are not comfortable writing code, you can record multiple macros and create multiple buttons, each one doing a different task.
Can I copy a button from one spreadsheet to another?
Yes. Right-click the button and select Cut. Open the other spreadsheet and click the cell where you want the button. Right-click and select Paste. The button and its assigned macro both copy over. If the macro refers to specific sheet names or cell ranges, you may need to edit it to match the new spreadsheet.
Is there a way to make a button that looks nicer or more professional?
The basic Form Control button is straightforward but plain. You can also insert a shape — like a rectangle or rounded box — and assign a macro to it the same way. Right-click the shape, select Assign Macro, and choose your macro. Shapes can be colored, have text inside them, and look more polished than the default button.
What happens to the button if I save the file as a PDF or send it to someone using Google Sheets?
Buttons and macros only work in Excel files. If you save as PDF, the button disappears and the macro does not run. If you open the file in Google Sheets, buttons and macros are not supported and will not appear. The spreadsheet data stays intact, but the automation is lost. Keep a copy in Excel format if you need the button to work.