Excel macros increase productivity and save time when creating a complex workbook or worksheet. Even if you start with some of the best Microsoft Excel templates, adding macros simplifies using your spreadsheet in the future. Here’s an explanation of what Excel macros are, what you can do with a macro, how to write and record macros to customize your workbook, and how to run macros to automate and speed up repetitive tasks.
An Excel macro is a series of commands stored in a workbook. A macro can replace actions that are as simple as a few menu choices and mouse clicks. By recording your actions, you can assign macros and replay them again with a tap of a shortcut key.
More complicated macros might be a complete program written in the Visual Basic editor using VBA code. VBA stands for Visual Basic for Applications, a programming language that includes special commands specific to Excel.
When you open macro-enabled workbooks, which are Excel files with an XLSM extension, Microsoft Office alerts you with a security warning. Macros can be dangerous and contain malicious code, so use caution.
If you don’t know the origin of a file or are unsure if the creator is trustworthy, don’t activate the macros. If you know the file is safe and want to use the VBA macros, choose Enable Content in the security warning.
You can bypass this warning by turning on macros in Microsoft Office Trust Center settings. Make sure you understand the risks if you do so. In the File tab, select Options, then choose Trust Center.
Excel macros are helpful. You can use macros to apply formatting to cells, rows, columns, and worksheets, sort and filter information, and perform data analytics to get a workbook ready for use.
Macros can build charts, graphs, and tables for creating reports. It imports or exports the data from other sources. Excel VBA macros can also generate documents and send emails, cutting your work to a minimum.
In short, open the Developer tab, select the Record Macro button, and type a macro name. You can store a macro in a Personal Macro Workbook that’s available from any worksheet or in This Workbook if you only want to use it on your current worksheets.
Excel records your actions. Perform the steps you want to repeat when you run the macro in the future. Click the Stop Recording button when you’re done. That way, you won’t add unnecessary steps.
If you don’t see the Developer tab, right-click the Excel ribbon and choose Customize the Ribbon from the drop-down menu. Tick the check box for Developer. The Developer tab appears between the View and Help tabs.
If you want to learn Visual Basic for Applications, start with our guide to creating Excel macros. If you’re a beginner, unfamiliar with VBA, or want to learn more about VBA for Excel, Microsoft’s macro tutorial is a good resource.
If you know VBA, open the Developer tab and select Visual Basic from the toolbar to open the VBA Editor. Alternatively, press Alt + F11 to toggle back and forth between the VBA Editor and your Excel workbook.
You can assign a keyboard shortcut to Excel macros written in VBA code, just as you can with recorded macros. Since you’re using macros to save time, triggering them with keystrokes is a great idea.
You can only create Excel macros on the desktop version of Excel. The desktop version of Excel is available for Windows PCs and Mac computers. While you can’t make new macros in Excel online, you can run macro-enabled workbooks. The Excel mobile app cannot run macros.
You can also use Excel Online to run macros on an inexpensive and long-lasting Chromebook. However, Microsoft didn’t make a desktop version for ChromeOS. If you want to record macros or create code for a spreadsheet, you’ll need another solution.
Google Sheets has macro recording and an Apps Script Editor where you can write custom code. It’s hard to beat Microsoft Excel, but Google Sheets is a worthy competitor that might be able to handle most of your needs.