Turn On Macros in Excel: A Step-by-Step Guide
In this article
To turn on macros in Excel, go to File > Options > Trust Center > Trust Center Settings > Macro Settings and select "Enable VBA macros." Because macros can contain malicious code, Excel disables them by default to protect your computer from security threats; you should only enable them for files from trusted sources.
Enabling macros allows you to run VBA (Visual Basic for Applications) scripts, which automate repetitive tasks, create custom functions, and build complex interactive tools within your spreadsheets. Depending on your security needs, you can choose to enable all macros globally or allow them on a case-by-case basis using the Message Bar.
What You'll Need
- A computer with Microsoft Excel installed (Windows or macOS).
- An Excel file that contains macros (usually saved with a .xlsm or .xlsb extension).
- Administrative permissions to change software settings if your computer is managed by an organization.
Step-by-Step
Note: Menu labels and locations may differ slightly depending on your version of Excel, your operating system, or your region.
- Open Microsoft Excel: Launch the application. You can do this with a blank workbook or by opening the specific file that requires macros.
- Access the Options Menu: Click on the File tab in the top-left corner of the ribbon. From the sidebar menu, click Options (usually located at the very bottom).
- Open the Trust Center: In the Excel Options window, click on Trust Center in the left-hand navigation pane.
- Enter Trust Center Settings: Click the Trust Center Settings... button located on the right side of the window. This opens a separate security configuration menu.
- Navigate to Macro Settings: In the Trust Center window, click Macro Settings from the left-hand list.
- Choose Your Security Level: You will see several options under "Macro Settings." Select the one that fits your needs:
- Disable all macros without notification: The strictest setting; macros will not run and you won't be told why.
- Disable all macros with notification: The recommended setting. Macros are disabled, but a yellow "Security Warning" bar appears at the top of the sheet when you open a file containing them, allowing you to click "Enable Content" for that specific session.
- Disable all macros except digitally signed macros: Only macros signed by a trusted publisher will run.
- Enable VBA macros: This turns on all macros automatically. Use this with caution, as it allows potentially harmful code to run without warning.
- Save Changes: Click OK on the Trust Center window, and then click OK again on the Excel Options window to apply the changes.
- Restart the File: If you had a workbook open while changing these settings, close it and reopen it for the macro permissions to take effect.
Common Mistakes
One of the most frequent errors is saving a macro-enabled workbook as a standard .xlsx file. Standard Excel workbooks cannot store VBA code; if you save a macro-enabled file as .xlsx, all your macros will be permanently deleted. Always use Save As and select Excel Macro-Enabled Workbook (.xlsm).
Another common mistake is enabling all macros globally for convenience. This creates a significant security vulnerability. If you download a file from an unknown source or an untrusted email, a malicious macro could execute automatically upon opening the file, potentially compromising your data or system.
Tips
For a balance of productivity and security, use the "Disable all macros with notification" setting. This ensures you are consciously deciding which files are safe to run rather than leaving the door open for every file you encounter.
If you frequently use a specific folder to store your own macro-enabled tools, you can add that folder as a "Trusted Location." Go to Trust Center Settings > Trusted Locations and add the folder path. Any file placed in that folder will run its macros automatically without triggering security warnings, while the rest of your system remains protected.
Troubleshooting
If you have enabled macros but they still won't run, try these steps in order:
- Check the File Extension: Ensure the file ends in .xlsm or .xlsb. If it is a .xlsx file, the macros have been stripped out and cannot be recovered.
- Check the Message Bar: Look for a yellow bar at the top of the spreadsheet that says "Security Warning: Macros have been disabled." You must click Enable Content for the macros to function in that session.
- Unblock the File: Windows sometimes blocks macros in files downloaded from the internet. Right-click the file in your folder, select Properties, and look for a "Security" section at the bottom of the General tab. If there is an Unblock checkbox, check it and click OK.
- Verify VBA Installation: In rare cases, Excel is installed without the "Visual Basic for Applications" component. If the Macro Settings menu is missing or grayed out, you may need to modify your Office installation via the Control Panel to include VBA.
- Check Group Policy: If you are using a work computer and the settings are grayed out or revert automatically, your IT department has likely disabled macros via Group Policy. You will need to contact your system administrator to request access.
Frequently Asked Questions
Why are macros disabled by default in Excel?
Macros are written in VBA code, which has the ability to interact with your operating system. Malicious actors can write macros that delete files, steal data, or install malware, so Microsoft disables them to prevent accidental execution of harmful scripts.
What is the difference between .xlsx and .xlsm?
The .xlsx format is the standard XML-based workbook and cannot contain macros. The .xlsm format is specifically designed to store macro-enabled workbooks; the "m" stands for macros.
Can I enable macros for just one specific file?
Yes. By choosing "Disable all macros with notification," you can click "Enable Content" on the yellow warning bar for a single file without changing the global security settings for all other workbooks.
Will enabling macros slow down my computer?
Simply enabling the ability to run macros does not slow down your computer. However, a poorly written or extremely complex macro running in the background can consume CPU and RAM, which may cause Excel to freeze or lag.
Do macros work on Excel for the Web?
No, VBA macros do not run in the web-based version of Excel. To run macros, you must open the file in the Excel desktop application.