Performing the same actions over and over again isn’t just boring, but it can also be a waste of time and a drain on your productivity. This is especially true for beginner Excel users, who might not realise that it’s easy to automate common tasks by recording a macro. But what is an Excel macro?
Excel macros allow you to automate many of the common tasks you’ll perform, from inserting formulas to formatting data. You don’t need to be a programmer to create them, as Excel can record your actions as you perform them. If you want to know how to record a macro in Excel, you’ll need to follow the steps below.
What Is an Excel Macro?
An Excel macro is a recorded set of instructions, created manually in VBA (Visual Basic for Applications) or recorded automatically using Excel’s Macro Recorder tool. A macro allows you to save any number of common actions, such as deleting blank columns, changing text formatting, or inserting new formulae into a workbook.
These saved actions can then be run with the click of a button or by using a specific keyboard shortcut. Each macro has a specific shortcut that you can use to quickly repeat the action.
If you use Excel to record a macro, you’ll reduce the time it takes to create or edit a spreadsheet, speeding up your workflow in the process.
How to Record a Macro in Excel
The easiest way to create a new macro in Microsoft Excel is to record it using the Macro Recorder tool, which you can use in Excel on Windows or Mac. Unfortunately, it isn’t possible to record a macro in Excel Online.
- To record a new macro in Excel, open a new or existing workbook. In the Developer tab on the ribbon bar, select the Record Macro button. Alternatively, press the Alt + T + M + R keys on your keyboard.
- In the Record Macro window, you can set a name for your macro to identify its purpose in the Macro name box, as well as provide a description for other users in the Description box. You can also add a shortcut key (such as Ctrl + T) to assign the new macro to a keyboard shortcut.
- In the Store macro in drop-down menu, you can set where you’d like to save the macro once it’s recorded, such as This Workbook (to save it to the open workbook), New Workbook (to save it to a new workbook), or Personal Macro Workbook (to allow you to use it in multiple workbooks). Select the OK button to begin recording once you’ve confirmed your choices.
- Once you select OK, the Excel Macro Recorder will be in recording mode. Each action you perform, from clicking a button to editing a cell, will be recorded. Perform the actions you wish to record as a macro at this point, then select the Stop Recording button in the Developer tab once you’re done.
Running, Editing or Deleting Existing Microsoft Excel Macros
Depending on the save location you selected in the Record Macro window, your recorded Macro will be ready to run in your open workbook or in a newly opened workbook.
- To run, edit, or delete the macro you’ve created, select Developer > Macros from the ribbon bar.
- In the Macro window, a list of available macros to run in your open workbook will be listed. To run the macro, select it from the list, then select the Run button. You can also use the keyboard shortcut you selected when you created the macro to run it instead.
- To make changes to the recorded macro instead, select the Edit button. This will open the Excel VBA editor, allowing advanced users to edit the VBA code and change how the macro runs. VBA beginners may find it easier to simply delete the macro and record it again.
- To delete the macro, select it from the list, then select the Delete button.
- Excel will ask you to confirm that you want to delete the macro. Select Yes to confirm this. Once deleted, you’ll need to record the macro again using the steps listed above.
Saving Excel Files with Recorded Macros
Excel workbooks are typically saved in the XLSX file format (or XLS for workbooks created in Excel 2007 and older). This file type supports most Excel data, but excludes any saved Excel macros.
To save an Excel file with recorded macros, you’ll need to use the XLSM file format instead.
- To save an Excel file as a macro-enabled workbook, select File > Save As > Browse.
- In the Save As window, select Excel Macro-Enabled Workbook (*.xlsm) from the drop-down menu. Choose a location to save the file, then select the Save button to save it.
- When you open the macro-enabled Excel file on another PC or Mac, you may need to authorize Excel to run any included macros first. Select the Enable Macros button to do this.
Sharing Excel Files with Recorded Macros
Excel macros are useful, but they also include potential security risks. If you open an Excel file containing macros from a source that you don’t recognize or trust, then you’re allowing that file to run dangerous code on your PC.
Because of this, online email providers like Gmail automatically block users from sending XLSM (macro-enabled Excel workbook) files to other users. If this happens, you may be able to use file sharing services like Google Drive to share it online with other users.
If you want to share your macro-enabled Excel file with another user nearby, then you could also look at local file transfer methods to share it with another PC or Mac, or with other devices like smartphones.
Macro-enabled Excel files can be packaged with viruses or other malware, so if you open an Excel file that you don’t trust, you may need to scan for malware afterwards to ensure that your PC isn’t compromised. Or scan the file itself before opening it.
Advanced Excel Tips and Tricks
Recording a macro is just one Excel trick that can help you save time, but there are other Excel features that can make you more productive as well. Power users might be interested in using Excel to scrape data online, while data analysts might be curious about how to use COUNTIFS, SUMIFS and AVERAGEIFS for extensive data analysis.
If you prefer to work as a team, or you’re struggling with a complicated Excel formula, you can also collaborate on Excel spreadsheets using a shared workbook. You may find that Google Sheets is a better option for online collaboration, however, with many of the same functions and features.