How to Enable Macros in Excel for Microsoft 365 (Office 365)

//

Michael Collins

To run macros in a workbook you trust, open it in Excel and select Enable Content on the yellow Security Warning bar under the ribbon. To change how Excel treats macros in every workbook, go to File > Options > Trust Center > Trust Center Settings > Macro Settings.

These instructions are for the Excel desktop app that comes with a Microsoft 365 subscription (sold as Office 365 until Microsoft renamed it) on Windows 11. Excel 2024, 2021, 2019 and 2016 on Windows use the same Trust Center labels. Excel for Mac and Excel for the web work differently and have their own sections below.

What Excel Does With Macros Out of the Box

A macro is a set of recorded or written instructions, stored in the workbook as VBA (Visual Basic for Applications) code, that repeats a task for you. Because the same code can also delete files or download malware, Excel does not run it automatically. The default setting is Disable VBA macros with notification: macros stay off, and Excel shows a bar that lets you turn them on for a file you trust.

That default is a good fit for most people. You rarely need to change the global setting; usually you only need to approve one workbook. Use this table to pick the right method:

Your situation Best method
You opened a workbook from a coworker or your own files and see a yellow bar Select Enable Content on the bar
You see a red SECURITY RISK bar with no Enable button Unblock the file in File Explorer, then reopen it
You run macro workbooks from the same folder every day Add that folder as a trusted location
No bar appears and macros never run Check the Trust Center setting, then the file type
You use Excel in a web browser Open the file in the desktop app

Turn On Macros for One Workbook

Use this when a workbook you trust opens with its macros switched off.

  1. Open the workbook in Excel. A yellow Security Warning bar appears below the ribbon with a message about disabled macros.
  2. Select Enable Content on that bar. The bar closes and the workbook’s macros can now run.
  3. If Excel asks whether to make the file a trusted document, select Yes.
Fictional macro enabled workbook open without a security warning (illustration)
Illustration: Fictional macro enabled workbook open without a security warning.

Once a file is a trusted document, Excel remembers it, and it opens with macros on next time. There are a few exceptions. If you move or rename the file, Excel asks again. Files opened from a temporary folder, such as an email attachment opened directly from Outlook, cannot become trusted, so save the attachment to a normal folder first. Templates cannot be made trusted either. Microsoft lists these rules on its Trusted documents page.

To take trust away later, go to File > Options > Trust Center > Trust Center Settings > Trusted Documents and clear all trusted documents. That resets every file at once, not just one.

Change the Macro Setting for Every Workbook

Changing this setting affects every workbook Excel opens, including ones that arrive by email later, so read the options before you pick one.

  1. In Excel, select File, then Options at the bottom of the left pane. The Excel Options window opens.
  2. Select Trust Center in the left pane.
  3. Select the Trust Center Settings button on the right. A second window, Trust Center, opens.
  4. Select Macro Settings in the left pane. The four macro options appear as radio buttons.
  5. Choose the option you want (see the table below), then select OK in the Trust Center window and OK again in Excel Options.
  6. Close the workbook and open it again so the new setting applies to it.
Excel Macro Settings with Disable VBA macros with notification selected (illustration)
Illustration: Excel Macro Settings with Disable VBA macros with notification selected.

If the Developer tab is on your ribbon, there is a shorter route: Developer > Macro Security (in the Code group) opens the same Macro Settings page. To add that tab, go to File > Options > Customize Ribbon and select the Developer check box under Main Tabs.

Excel labels its options slightly differently from Word and PowerPoint. In Excel for Microsoft 365 they read:

Option in Excel What happens when you open a workbook with macros
Disable VBA macros without notification Macros are off and no bar appears. Only files in trusted locations can run macros.
Disable VBA macros with notification (default) Macros are off, and the Security Warning bar lets you enable them file by file.
Disable VBA macros except digitally signed macros Signed macros from a publisher you already trust can run; unsigned macros are disabled without a prompt.
Enable VBA macros (not recommended, potentially dangerous code can run) Every macro runs without asking, including harmful ones.

Below the four options there is a separate check box, Enable Excel 4.0 macros when VBA macros are enabled. Excel 4.0 (XLM) macros are an older macro language found in very old workbooks. Leave it cleared unless a specific old file needs it.

Some guides tell readers to pick the “enable all” option. That is not the safest choice. Enable VBA macros turns off the warning for every file, so a malicious attachment would run its code the moment you open it. Keep the default and use Enable Content or a trusted location for the files you need. Microsoft’s macro security settings page for Excel gives the same advice.

Two more details from that page are worth knowing. Changes here apply to Excel only, not Word or PowerPoint. And on a work or school computer, your IT administrator can lock these options; if they are grayed out, ask IT rather than looking for a workaround.

The Developer Macro Settings section on the same page has a check box called Trust access to the VBA project object model. That is for developers whose programs write VBA code into workbooks. You do not need it to run ordinary macros.

Unblock a Macro Workbook Downloaded From the Internet

Since mid 2022, Excel for Microsoft 365 on Windows blocks macros in files that came from the internet, such as email attachments and browser downloads. Instead of the yellow bar, you see a red SECURITY RISK bar saying Microsoft has blocked macros from running because the source of the file is untrusted. That bar has no Enable Content button, and changing the Trust Center option does not lift the block.

Comparison of the yellow Security Warning bar with an Enable Content button and the red Security Risk bar that blocks macros in files from the internet
Illustration: the yellow bar lets you enable macros; the red bar means the file must be unblocked first.

Windows marks downloaded files with a tag often called the Mark of the Web. If you are sure the file is safe, remove that tag.

  1. Close the workbook in Excel.
  2. In File Explorer, right-click the file and select Properties.
  3. On the General tab, select the Unblock check box, then select OK.
  4. Open the workbook again. You now see the normal yellow bar, where Enable Content works.
Yellow Excel security warning with Enable Content available for an example workbook (illustration)
Illustration: Yellow Excel security warning with Enable Content available for an example workbook.

If there is no Unblock check box, the file may be on a network share; ask your IT team. Files that OneDrive syncs to your PC, and files you open from SharePoint or OneDrive with Open in Desktop App, do not get this tag. Microsoft explains the full behavior in Macros from the internet are blocked by default in Office. This block applies to Office on Windows only; Excel for Mac and Excel for the web are not affected.

Use a Trusted Location for Files You Run Often

A trusted location is a folder whose files Excel treats as safe: workbooks stored there open with macros on and skip the Trust Center checks, including the internet block above. That makes it convenient for a folder of your own macro tools, and risky for any folder where downloads land.

  1. Go to File > Options > Trust Center > Trust Center Settings.
  2. Select Trusted Locations in the left pane.
  3. Select Add new location.
  4. Select Browse, pick the folder, and select OK.
  5. Select OK until all the windows close.
Dedicated example Excel Macros folder listed as a trusted location (illustration)
Illustration: Dedicated example Excel Macros folder listed as a trusted location.

Pick a dedicated folder such as C:\Users\YourName\Documents\Excel Macros, never your Downloads folder. Microsoft also advises against using network folders as trusted locations. To remove one later, return to Trusted Locations, select the folder, and select Remove. The steps match Microsoft’s trusted location instructions.

Confirm That Macros Run

The quickest test is a tiny macro of your own, since you know exactly what it does.

  1. On the Developer tab, select Record Macro in the Code group.
  2. Type a name such as CurrencyFormat in Macro name and select OK. Recording starts.
  3. Select a few cells with numbers and apply the Currency format (the same result as when you add a dollar symbol automatically in Excel).
  4. Select Stop Recording on the Developer tab.
  5. Type numbers in other cells, select them, then choose Developer > Macros, pick CurrencyFormat, and select Run. The new cells take the currency format.
Example Excel cells formatted as currency after the sample macro (illustration)
Illustration: Example Excel cells formatted as currency after the sample macro.

If the cells change, macros work. You can check a cell’s formatting in Excel through the Format Cells dialog to see exactly what the macro applied.

When you save, choose Excel Macro-Enabled Workbook (.xlsm) in Save as type. If you save as a regular .xlsx workbook, Excel warns that the workbook contains macros or VBA code, and selecting Yes in that message saves the file without them.

When Macros Still Do Not Run

What you see Likely cause and fix
No yellow bar and macros silently fail The setting is Disable VBA macros without notification. Switch to the default with notification.
Red SECURITY RISK bar Internet file. Unblock it in Properties or move it to a trusted location.
Options grayed out in Trust Center Your organization manages macro policy. Contact IT.
Macros vanished after saving The file was saved as .xlsx. Rebuild from an older copy saved as .xlsm.
Bar comes back every time The file was moved or opened from a temporary folder, so it is not a trusted document.
Antivirus warning on open Excel lets compatible antivirus scan macro workbooks first. Do not enable a file your antivirus flags.

Excel for Mac and Excel for the Web

Excel for Mac keeps its macro setting in a different place. Open the Excel menu, select Preferences, then Security. Under Macro Security you can choose Enable all macros, Disable all macros with notification (the default) or Disable all macros without notification. Microsoft’s Mac macro page warns that the first option lets good and bad macros run with no warning, so the default is the better choice here too.

Excel for the web cannot record, run or edit VBA macros at all. You can still open and edit a macro workbook in the browser, and its macros stay in the file. To run them, select Open in Desktop App above the ribbon, then use Enable Content in the desktop app.

Macro Questions Readers Ask

Is it safe to click Enable Content?

It is safe when you know where the file came from and expected it to contain macros. Be wary of an unexpected attachment, or of a document whose text tells you to enable content to see it: that is a common trick used to get malware running.

Does enabling macros in Excel turn them on in Word too?

No. Each Office app keeps its own Trust Center macro setting, so a change in Excel leaves Word, PowerPoint and Outlook as they were.

How do I turn macros back off?

Go to File > Options > Trust Center > Trust Center Settings > Macro Settings and select Disable VBA macros with notification (or without notification if you never use macros). To stop a single file from running macros automatically, clear trusted documents in the same window or move the file out of any trusted location.

Do I need macros for every repetitive task?

Not always. Many cleanup jobs are easier with a formula, for example using IFERROR to show 0 instead of #N/A in Excel. Macros make sense when the same sequence of clicks repeats across many sheets or files.

Why did macros that used to work stop after an update?

The most common reason on Windows is the internet block added in 2022: workbooks you downloaded or received by email now open with the red SECURITY RISK bar. Unblock the file or store it in a trusted location, as described above.