To enable a macro in Excel for Microsoft 365 on Windows, open a workbook you trust and select Enable Content in its security warning. If Excel blocks a downloaded file because it came from the internet, close Excel, right-click the file in File Explorer, choose Properties, select Unblock if it appears, and reopen the workbook. Avoid turning on all macros globally: VBA code can run actions on your computer, so only enable macros when you trust the file and its source.
First identify the warning
Excel disables macros by default because a macro is executable code, not just spreadsheet data. A legitimate macro can automate repetitive work, but a malicious one can alter files, collect information, or perform other actions using your account. The right fix depends on which warning appears, so read the message before changing a setting.
- Macros have been disabled or a yellow security bar: Excel may offer an Enable Content button. Use it only if you trust the workbook.
- Microsoft has blocked macros from running because the source of this file is untrusted: the file may carry an internet-origin mark. The Enable Content button may not be available; see the Unblock steps below.
- Protected View: Excel opened the file in a restricted state, often because it came from the internet or an email attachment. Do not choose Enable Editing or enable macros until you have checked that the file is expected and trustworthy.
- No warning, but the macro does not run: the file might not contain VBA, might be saved in the wrong format, or your organization may enforce a security policy.
A warning is not proof that a file is harmful, and the absence of a warning is not proof that it is safe. Treat the source and purpose of the workbook as more important than the appearance of the banner.
Enable macros for one workbook
If Excel displays a security warning for a workbook you expected and trust, use its per-file control rather than lowering security for every spreadsheet. In many cases, the steps are simply to open the workbook and select Enable Content in the message bar. Depending on the version and warning, Excel may then allow macros for that workbook during the current session or add it as a trusted document.
- Confirm the workbook came from the person or organization you expected. If it arrived unexpectedly, verify with the sender through another channel.
- Check the filename and file type. Macro-enabled Excel files commonly end in
.xlsm,.xlsb, or.xlam. - If the workbook opens in Protected View, first decide whether the file is safe. Only then select Enable Editing, if offered, and use Enable Content if Excel subsequently displays the macro warning.
- Close and reopen the file if Excel asks you to, then check whether the intended button or automated task works.
Do not click a workbook button just to see what it does. A macro may run when a button is clicked, when the workbook opens, or in response to another event. If you are unsure what a workbook is supposed to do, ask its author or your IT team before enabling it.
Change the Trust Center macro setting
Excel for Windows has global VBA macro settings, but changing them affects how Excel handles other workbooks too. To view them, go to File > Options > Trust Center > Trust Center Settings > Macro Settings. The labels can vary slightly across releases and managed installations. Choose a setting only if you understand the wider effect.
- Disable VBA macros with notification disables macros while allowing a warning and, where permitted, a choice for an individual file. This is generally the useful option when you want to decide workbook by workbook.
- Disable VBA macros except digitally signed macros allows macros from publishers whose signatures are trusted, while disabling other VBA macros. A valid signature helps identify whether code has changed since signing; it does not prove that the code is harmless.
- Disable VBA macros without notification blocks macros without showing the usual prompt. This can make it less obvious why a workbook’s automation is unavailable.
- Enable VBA macros permits VBA macros broadly and is not recommended for everyday use. It does not make a workbook trustworthy or scan its code for safety.
For most people, leave Excel’s default protection in place and enable only a known, needed workbook. If a setting is unavailable or grayed out, a work or school administrator may control it through organizational policy. Do not try to bypass that control; ask the administrator how to use an approved macro-enabled file.
Unblock a file downloaded from the internet
Windows can mark files downloaded from the internet or received as attachments as coming from an untrusted source. Current Microsoft 365 versions of Office may block VBA macros in such files, even if the Trust Center is configured to show macro notifications. If you can verify the file’s origin and need its macros, remove the internet mark only for that file.
- Save the file to a location on your Windows computer, then close it in Excel.
- In File Explorer, right-click the workbook and choose Properties.
- On the General tab, look near the bottom for a security message and an Unblock checkbox. If it is present and you trust the file, select it, choose Apply, and then OK.
- Reopen the workbook. Excel may still show a macro warning; review it and enable the content only if appropriate.
The Unblock checkbox may not appear, depending on how the file was obtained, your Windows version, or your organization’s settings. If the file is stored in a compressed archive, the mark may be attached to the archive; ask the sender for a trusted copy or consult your IT team rather than changing broad security settings. Unblocking removes a warning-related restriction; it does not check the workbook for malware.
Trusted locations and trusted publishers
A trusted location is a folder Excel treats as a safer place for files, which can reduce security prompts for workbooks stored there. In Windows, manage these folders under File > Options > Trust Center > Trust Center Settings > Trusted Locations. Add a folder only when you control it and understand what will be stored there. Any workbook placed in a trusted location may receive more permissive treatment, so a general-purpose Downloads folder or shared folder is a poor choice.
A digital signature can help show who published a macro and whether the VBA project has changed since signing. If Excel asks whether to trust a publisher, verify the publisher through a reliable channel before accepting. A signature is an identity and integrity check, not a safety guarantee: a trusted publisher could still distribute code you do not want to run, or its signing credentials could be misused.
Trusted locations and publishers are most useful in managed environments where a known team distributes recurring automation. For a one-time workbook from a colleague, enabling that specific document is usually easier to limit and understand than creating a permanent exception.
Check the workbook format and macro contents
Excel’s standard .xlsx format does not store VBA macros. If you open a macro-enabled workbook and save it as .xlsx, Excel warns that VBA content cannot be saved in that format; continuing can remove the macros. Use .xlsm for a macro-enabled workbook, .xlsb for an Excel binary workbook that can contain macros, or .xlam for an Excel add-in.
If a workbook is supposed to contain macros but Excel shows none, check the file extension and ask the author whether a macro-free copy was sent by mistake. Renaming an .xlsx file to .xlsm does not restore VBA code. Likewise, enabling macros cannot make an ordinary workbook contain automation that was never saved in it.
When you need to inspect VBA, you can open the Visual Basic Editor from Excel with Alt+F11 on Windows. The editor may be unavailable if the workbook has no VBA project, the project is protected, or policy restricts access. Inspection can help a knowledgeable user understand a macro, but unfamiliar code can be difficult to assess; do not treat a quick glance as a security review.
Common reasons macros still will not run
- Your organization manages the setting: Group Policy or another administrative control can override personal Trust Center choices. Contact IT for the approved process.
- The internet block remains: a downloaded file may be blocked even when notifications are enabled. Check the file’s Windows Properties, but do not unblock a file whose source you cannot verify.
- The workbook is read-only or protected: these conditions can restrict editing or particular actions, although they are not the same thing as macro security. Review the exact message Excel displays.
- The file is in an unsupported format: an
.xlsxcopy cannot preserve VBA. Request or save an appropriate macro-enabled format. - The macro is failing rather than disabled: a broken reference, outdated code, missing file, or changed workbook layout can cause an error after macros are allowed. Note the exact error and ask the workbook’s owner to investigate.
- The macro depends on a feature unavailable in your environment: some automation may rely on Windows components, add-ins, network drives, or permissions that are not available on another computer.
Distinguish a security block from a VBA error. A security banner indicates Excel has not allowed the code to run; an error after you deliberately enable a trusted workbook may instead indicate a problem in the macro or its dependencies. Repeatedly changing security settings will not repair faulty code.
Windows, Mac, and Excel for the web
These steps primarily describe Excel for Microsoft 365 on Windows. On a Mac, macro support is available in desktop Excel, but settings and menus differ by release. Look under Excel > Preferences or Excel > Settings for Security & Privacy or Macro Security, then review the available macro choices. Do not assume that Windows instructions such as right-clicking a file and selecting an Unblock checkbox apply on macOS.
Excel for the web does not run VBA macros. You can open and edit many workbook types in a browser, but VBA automation requires desktop Excel. If the workbook needs a macro, open it in the desktop application and follow the security prompts there. A workbook may also use Office Scripts or other automation, which is different from VBA and has separate capabilities and controls.
Keyboard shortcuts vary by operating system and keyboard configuration. On Windows, Alt+F11 opens the Visual Basic Editor in desktop Excel. On Mac, use the application menus or check the shortcut shown for your Excel version; Windows shortcuts should not be assumed to work unchanged.
Safe habits before enabling macros
Use a simple rule: enable code only when you can explain why the workbook needs it and you have a trustworthy source for the file. A familiar filename or logo is not enough, since both can be copied. Be especially careful with unexpected attachments, files from public download sites, and workbooks that pressure you to enable content to view ordinary data.
- Confirm an unexpected attachment with its purported sender using a separate message or call.
- Prefer files shared through your organization’s approved storage and distribution process.
- Keep Microsoft 365 and Windows updated, and follow your organization’s endpoint-security guidance.
- Do not set Excel to enable every macro just to solve one workbook’s warning.
- If a workbook asks you to lower protections or disable security software, stop and ask the sender or IT team.
These precautions preserve the convenience of legitimate spreadsheet automation without turning every workbook into executable code you automatically trust. When the right answer is unclear, leaving macros disabled is the safer choice until the file can be verified.
Frequently Asked Questions
How do I enable macros in Excel when the yellow bar appears?
For a workbook you trust, select Enable Content in the security warning. If the warning is absent or the file is blocked as untrusted, identify the cause before changing any settings.
Why does Excel say Microsoft blocked macros because the source is untrusted?
Windows may mark a file downloaded from the internet or received as an attachment. If you have verified the file, close Excel and check for an Unblock option in the file’s Windows Properties. Your organization may control whether this is allowed.
Should I choose Enable VBA macros in Trust Center?
Usually not. That setting permits macros broadly. Keep notifications or your organization’s approved policy, and enable only files whose source and purpose you trust.
Can Excel for the web run macros?
No. VBA macros run in desktop Excel, not Excel for the web. Open the workbook in the desktop application if its VBA automation is required.
Why did my macros disappear after saving the workbook?
It may have been saved as .xlsx, a format that cannot store VBA. Ask for the original macro-enabled file or save a VBA workbook in a suitable format such as .xlsm.
What if macro settings are grayed out?
Your employer or school may manage the settings centrally. Contact the organization’s IT administrator rather than trying to work around its policy.
Related
- Excel: Copy Subtotal Rows Only Without Detail Rows
- How to Hyperlink to Another Cell in Excel
- How to Group Rows in Excel and Hide Them
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- VBA ArrayList: How to Create and Use It in Excel VBAIn VBA, an ArrayList is a resizable, zero-based list that you can create on Windows with CreateObject("System.Collections.ArrayList"). It…
- Excel VBA Progress Bar: How to Build a Responsive OneAn Excel VBA progress bar shows how much of a long-running macro has finished. For a visual bar,…
- Excel VBA: Create an Outlook Email Draft in WindowsYes. In Excel for Microsoft 365 on Windows, VBA can use classic Outlook’s object model to create an…
- Excel VBA: What It Does, How It Works, and When to Use ItExcel VBA is the programming language built into the desktop versions of Microsoft Excel for automating tasks and…
- Excel Macro to Copy and Paste Data: A Practical GuideTo copy a data range between worksheets in Excel for Microsoft 365 on Windows, use a VBA macro…
- VBA Resize Pictures to Fit in Excel Cells AutomaticallyTo resize pictures to fit inside Excel cells with VBA, run a macro that finds each picture, scales…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.