This article was co-authored by wikiHow staff writer, Hannah Dillon. Hannah Dillon is a Technology Writer and Editor at wikiHow. She graduated with a B.A. in Journalism from North Dakota State University in 2013 and has since worked in the video game industry as well as a few newspapers. From a young age Hannah has cultivated a love for writing and technology, and hopes to use these passions in tandem to help others in the articles she writes for wikiHow.
This article has been fact-checked, ensuring the accuracy of any cited facts and confirming the authority of its sources.
This article has been viewed 785,951 times.
Learn more...
This wikiHow teaches you how to enable, create, run, and save macros in Microsoft Excel. Macros are miniature programs that allow you to perform complex tasks, such as calculating formulas or creating charts, within Excel. Macros can save significant amounts of time when applied to repetitive tasks, and thanks to Excel's "Record Macro" feature, you don't have to know anything about programming in order to create a macro.
Creating & Using Excel Macros
- Go to View > Macros > Record Macro to set up your macro and begin recording. Click the Macros button again and click Stop Recording when you're done.
- Click the Macros button and choose View Macros to view and run your macros.
- Save your workbook as an .XLSM file to ensure that macros are enabled in the spreadsheet when you or another user opens the spreadsheet the next time.
Steps
Recording a Macro
-
Enter any necessary data. If you opened a blank workbook, enter any data that you want to use before proceeding. Otherwise, open an Excel sheet that you've previously made before getting started.
-
Click the View tab. It's at the top of the Excel window.Advertisement
-
Click Macros. It's at the end of the ribbon, and it has an icon of a spreadsheet with a red scroll in front of it.
-
Click Record Macro…. It's in the dropdown menu. A pop-up window will appear.
-
Enter a name for the macro. In the "Macro name" text box, type in the name for your macro. This will help you identify the macro later.
-
Create a shortcut key combination if you like. Press the Ctrl key along with another letter key (e.g., the E key) to create the keyboard shortcut. You can use this keyboard shortcut to run the macro later.
- On a Mac, the shortcut key combination will end up being ⌥ Option+⌘ Command and your key (e.g., ⌥ Option+⌘ Command+T).
-
Make sure "This Workbook" is selected in the "Store macro in" field. This is the default option, but you may need to select it if you see a different option selected. Your macro will be stored inside your spreadsheet, making it possible for anyone who has the spreadsheet to access the macro.
-
Add a macro description (optional). If you want to add a description about what this macro does, type it into the "Description" field. Otherwise, you can skip this and move to the next step.
-
Click OK. It's at the bottom of the window. Doing this saves your macro settings and begins recording.
-
Perform the macro's steps. Any step you perform between clicking OK and clicking Stop Recording while be added to the macro. For example, if you wanted to create a macro that turns two columns' worth of data into a chart, you would do the following:
- Click and drag your mouse across the data to select it.
- Click Insert
- Select a chart shape.
- Click the chart that you want to use.
-
Click Stop Recording. It's in the View tab, under the Macros button. To view your macros, click the Macros button again and choose View Macros. Your macro will be listed, and you'll be able to run, edit, or configure your macro as you see fit.
Running a Macro
-
Click the View tab. This option is at the top of the Excel window.
- You can also just press the key combination you set for the macro. If you do so, the macro will run, and you can skip the rest of this method.
-
Click Macros. You'll find it in the View tab's toolbar. A dropdown menu will open.
-
Click View Macros. A pop-up window with all of your macros will appear.
-
Select your macro. Click the name of the macro that you want to run.
-
Click Run. It's on the right side of the window. Your macro will begin running.
-
Wait for the macro to finish running. Depending on how large your macro is, this can take several seconds.
Saving a Macro-Enabled Spreadsheet
-
Understand why you have to save the spreadsheet with macros enabled. If you don't save your spreadsheet as a macro-enabled spreadsheet (XLSM format), the macro won't be saved as part of the spreadsheet, meaning that other people on different computers won't be able to use your macro if you send the workbook to them.
-
Click File. It's in the upper-left corner of the Excel window (Windows) or the screen (Mac). Doing so will prompt a drop-down menu.
-
Click Save As. This option is on the left side of the window (Windows) or in the drop-down menu (Mac).
-
Double-click This PC. It's in the column of save locations near the left side of the window. A "Save As" window will open.
- Skip this step on a Mac.
-
Enter a name for your Excel file. In the "Name" text box, type in the name for your Excel spreadsheet.
-
Change the file format to XLSM. Click the "Save as type" drop-down box, then click Excel Macro-Enabled Workbook in the resulting drop-down menu.[1]
- On a Mac, you'll replace the "xlsx" at the end of the file's name with xlsm.
-
Select a save location. Click a folder in which you want to save the Excel file (e.g., Desktop).
- On a Mac, you must first click the "Where" drop-down box.
-
Click Save. It's at the bottom of the window. Doing so will save your Excel spreadsheet to your selected location, and your macro will be saved along with it.
- When you open a macro-enabled spreadsheet, you'll need to click the Enable Content button at the top of the screen to use the macros saved within the workbook.
Community Q&A
-
QuestionCan I use a macro that I create in other spreadsheets and future spreadsheets on the same pc?
Community AnswerYes, you can use a macro that you crate in other spreadsheets and future spreadsheets on the same pc. -
QuestionHow can I write macros that will change a spreadsheet as soon as I create it?
Community AnswerYou will first need a basic understanding of VBA. There are many tutorials on this.
Video
Tips
-
Macros are generally useful for automating tasks that you must perform often, such as calculating payroll at the end of the week.Thanks
Warnings
- Although most macros are benign, some macros can maliciously change or delete information on your computer. Never open a macro from a source that you don't trust.Thanks
References
About This Article
1. Enable Developer options in Excel.
2. Click the Developer tab.
3. Click Record Macro.
4. Enter the macro name and details.
5. Click OK.
6. Perform the macro's steps.
7. Click Stop Recording.


























