How to enable and disable macros in Excel (2024)

The article looks at how to turn on macros in Excel, explains the basics of macro security and shows how to adjust the security settings to run VBA codes safely.

Like almost any technology, macros can be used for both good and evil. Therefore, in Microsoft Excel, all macros are disabled by default. This tutorial covers different ways to enable macros in Excel and explains potential risks associated with that.

Macro security in Excel

Before you go enable macros in your worksheets, it's important to understand how dangerous they can possibly be.

Though VBA codes are very effective in automating complex and repetitious tasks, they are a significant source of risk from the security point of view. A malicious macro that you run unwittingly may damage or completely delete files on your hard drive, mess up your data, and even corrupt your Microsoft Office installation. For this reason, Excel's default setting is to disable all macros with notification.

How to avoid these dangers? Just follow one simple rule: enable only safe macros – ones that you've written or recorded yourself, macros from trusted sources, and VBA codes that you have reviewed and fully understand.

How to enable macros for individual workbooks

There are two ways to turn on macros for a certain file: directly from the workbook and through the Backstage view.

Enable macros via security warning bar

With the default macro settings, when you first open a workbook containing macros, the yellow security warning bar appears at the top of the sheet right under the ribbon:
How to enable and disable macros in Excel (1)

If the Visual Basic Editor is open at the time you are opening the file with macros, the Microsoft Excel Security Notice will be displayed:
How to enable and disable macros in Excel (2)

If you trust the source of the file and know that all the macros are secure, click the Enable Content or Enable Macros button. This will turn on the macros and make the file a trusted document. The next time you open the workbook, the security warning won't appear.

If the source of the file is unknown and you don't want to enable macros, you can click the 'X' button to close the security warning. The warning will disappear, but macros will remain disabled. Any attempt to run a macro will result in the following message.
How to enable and disable macros in Excel (3)

If you've disabled macros accidentally, simply re-open the workbook, and then click the Enable Content button on the warning bar.

Turn on macros in Backstage view

Another way to enable macros for a specific workbook is via the Office Backstage view. Here's how:

  1. Click the File tab, and then click Info in the left menu.
  2. In the Security Warning area, click Enable Content > Enable All Content.

As with the previous method, your workbook will become a trusted document.
How to enable and disable macros in Excel (4)

What you should know about trusted documents in Excel

Enabling macros through either a message bar or Backstage view makes the file a trusted document. However, some Excel files cannot be made trusted documents. For examples, files opened from an unsafe location such as the Temp Folder, or if the system administrator has set the security policy in your organization to disable all macros without notification. In such cases, the macros are only enabled for a single time. On the next opening of the file, Excel will prompt you to enable the content again. To avoid this, you can change your Trust Center settings or save the file to a trusted location.

Once a particular workbook becomes a trusted document, there is no way to un-trust it. You can only clear the Trusted Documents list. For this, do the following:

  1. Click File > Options.
  2. On the left side, select Trust Center, and then click Trust Center Settings.
  3. In the Trust Center dialog box, select Trusted Documents on the left.
  4. Click Clear, and then click OK.

This will make all previously trusted files untrusted. When you open such a file, the security warning will show up.
How to enable and disable macros in Excel (5)

Tip. If you do not want to make any documents trusted, tick the Disable Trusted Documents box. You will still be able to turn on macros on opening a workbook, but only for the current session.

How to resolve "Microsoft has blocked macros"

In new versions of Excel, Microsoft has changed the behavior for macro-enabled files downloaded from the internet. Instead of the yellow Security Warning that allows enabling the content straight away, it now often displays a read Security Risk bar with this message: Microsoft has blocked macros from running because the source of this file is untrusted.

How to enable and disable macros in Excel (6)

ClickingLearn Morewon't unblock the macro – it just takes you to a web page explaining the reasons and solutions.

How to unblock a macro workbook in Excel

To unblock a macro that is blocked by Microsoft, this is what you need to do:

  1. Close the workbook containing the blocked macro.
  2. In File Explorer, browser to the location where the workbook is saved.
  3. Right-clickthe file, and select Properties from the context menu.
  4. In the Properties dialog box, check the Unblock box, and then click OK.

How to enable and disable macros in Excel (7)

How to enable macros for one session

In some situations, it stands to reason to enable macros only for a single time. For example, when you received an Excel file with VBA code that you'd like to investigate, but you do not wish to make this file a trusted document.

The following instructions will guide you through the steps to enable macros for the duration that the file is open:

  1. Click the File tab > Info.
  2. In the Security Warning area, click Enable Content > Advanced Options.
  3. In the Microsoft Office Security Options dialog box, select Enable content for this session, and click OK.
    How to enable and disable macros in Excel (8)

This turns on macros for one time. When you close the workbook, and then reopen it, the warning will appear again.

How to enable macros in all workbooks via Trust Center

Microsoft Excel determines whether to allow or disallow VBA codes to run based on the macro setting selected in the Trust Center, which is the place where you configure all the security settings for Excel.

To get macros enabled in all Excel workbooks by default, this is what you need to do:

  1. Click the File tab, and then click Options at the very bottom of the left bar.
  2. On the left-side pane, select Trust Center, and then click Trust Center Settings… .
    How to enable and disable macros in Excel (9)
  3. In the Trust Center dialog box, click Macro Settings on the left, select Enable all macros and click OK.
    How to enable and disable macros in Excel (10)

Notes:

  • The option you set via the Trust Center becomes the new default macro setting and applies globally to all of your Excel files. If you want to enable macros for only specific workbooks, save them in a trusted location instead.
  • Enabling all macros in all workbooks makes your computer vulnerable to potentially dangerous codes.

Excel macro settings explained

Bellow we will briefly explain all macro settings in the Trust Center to help you make an informed decision:

  • Disable all macros without notification - all macros are disabled; no warning will show up. You won't be able to run any macros except the ones stored in trusted locations.
  • Disable all macros with notification (default) - macros are disabled, but you can enable them on a case-by-case basis.
  • Disable all macros except digitally signed macros – unsigned macros are disabled with notifications. Macros digitally signed with a special certificate by a trusted publisher are allowed to run. If you have not trusted the publisher, Excel will prompt you to trust the publisher and enable the macro.
  • Enable all macros (not recommended) - all macros are allowed to run, including potentially malicious codes.
  • Trust access to the VBA project object model - this setting controls programmatic access to the object model of Visual Basic for Applications. It's disabled by default to prevent unauthorized programs from changing your macros or building self-replicating harmful codes.

When changing the Trust Center settings, please keep in mind that they apply only to Excel, not to all Office programs.

Enable macros permanently in a trusted location

Instead of manipulating the global macro settings, you can configure Excel to trust specific locations on your computer or local network. Any Excel file in a trusted location opens with macros enabled and without security warnings, even if the Disable all macros without notification option is selected in the Trust Center settings. This lets you run macros in certain workbooks when all other Excel macros are disabled!

An example of such files in the Personal Macro Workbook – all VBA codes in that workbook are available for you to use whenever you start Excel, regardless of your macro settings.

To view the current trusted locations or add a new one, carry out these steps:

  1. Click File > Options.
  2. On the left-hand pane, select Trust Center, and then click Trust Center Settings… .
  3. In the Trust Center dialog box, select Trusted Locations on the left side. You will see a list of the default trusted locations. These locations are important for the correct work of Excel add-ins, macros and templates, and should not be changed. Technically, you can save your workbook to one of the Excel default locations, but it's better to create your own one.
  4. To set up your trusted location, click Add new location… .
    How to enable and disable macros in Excel (11)
  5. In the Microsoft Office Trusted Locations dialog box, do the following:
    • Click the Browse button to navigate to the folder that you want to make a trusted location.
    • If you wish any subfolder of the selected folder to be trusted too, check the Subfolders of this location are also trusted box.
    • Type a short notice in the Description field (this can help you manage multiple locations) or leave it empty.
    • Click OK.

    How to enable and disable macros in Excel (12)

  6. Click OK twice to close the remaining dialog boxes.

Done! You can now place your workbook with macros in your own trusted location and do not bother about Excel's security settings.

Tips and notes:

  • Please be very careful when choosing a trusted location. Because Excel automatically enables all macros in all workbooks that are stored in trusted locations, they become kind of loopholes in your security system, vulnerable to macro viruses and hacking attacks. Never make any temporary folder a trusted source. Also, be cautious with the Documents folder, rather create a subfolder and designate it as a trusted location.
  • If you've mistakenly added a certain folder to the list of trusted locations, select it and click the Remove button.

How to enable macros programmatically with VBA

On Excel forums, many people ask if it is possible to enable macros programmatically on opening a workbook and disable them before exiting. The immediate answer is "No, it's not possible". Because macro security is critical for the security of Excel, Microsoft designed any VBA code to only be triggered by a user click.

However, when Microsoft closes a door, the user opens a window :) As a workaround, someone suggested a way to force the user to enable macros with a kind of "splash screen" or "instruction sheet". The general idea is as follows:

You write a code that makes all the worksheets but one very hidden (xlSheetVeryHidden). The visible sheet (splash screen) says something like "Please enable macros and re-open the file" or provides more detailed instructions.

If macros are disabled, the user can only see the "Splash Screen" worksheet; all other sheets are very hidden.

If macros are enabled, the code unhides all the sheets, and then makes them very hidden again when the workbook closes.

How to disable macros in Excel

As already mentioned, Excel's default setting is to disable macros with notification and allow users to enable them manually if they want to. If you'd like to disable all macros silently, without any notification, then choose the corresponding option (the first one) in the Trust Center.

  1. In your Excel, click the File tab > Options.
  2. On the left-side pane, select Trust Center, and then click Trust Center Settings… .
  3. In the left menu, select Macro Settings, choose Disable all macros without notification, and click OK.
    How to enable and disable macros in Excel (13)

That's how you can enable and disable macros in Excel. I thank you for reading and hope to see you on our blog next week!

You may also be interested in

  • Excel macro tutorial for beginners with examples
  • How to record a macro in Excel
  • How to run Excel macros
  • How to use and store custom functions in Excel
  • How to make macros available in all workbooks
How to enable and disable macros in Excel (2024)

FAQs

How to enable and disable macros in Excel? ›

In your Excel, click the File tab > Options. On the left-side pane, select Trust Center, and then click Trust Center Settings… . In the left menu, select Macro Settings, choose Disable all macros without notification, and click OK.

How do I enable or disable macros in Excel? ›

In your Excel, click the File tab > Options. On the left-side pane, select Trust Center, and then click Trust Center Settings… . In the left menu, select Macro Settings, choose Disable all macros without notification, and click OK.

How to check if macros are enabled in Excel? ›

Open Microsoft Excel again and Press Alt+F11 to check whether Macros have been enabled. If you are not able to enable Macros from here, then it implies that while installing Microsoft Office on your machine, Macros is not installed.

How do I enable macros in Excel not working? ›

Verify Macro Settings:

Step 1: Open Excel, go to "File," then "Options." Step 2: Access "Trust Center" > "Macro Settings." Step 3: Enable macros, restart Excel, and test.

How do I access macros in Excel? ›

Run a macro from the Developer tab
  1. Open the workbook that contains the macro.
  2. On the Developer tab, in the Code group, click Macros.
  3. In the Macro name box, click the macro that you want to run, and press the Run button.
  4. You also have other choices: Options - Add a shortcut key, or a macro description.

How do I stop Microsoft from blocking macros in Excel? ›

Remove Mark of the Web from a file

To unblock macros in a file, like one from the internet or an email attachment, remove the Mark of the Web on your local device. To remove, right-click on the file, choose Properties, and then select the Unblock checkbox on the General tab.

How to check if a macro is running in Excel? ›

By single stepping through a macro, you can observe the flow of the macro and the results of each action, and isolate any action that causes an error or produces unwanted results. Right-click the macro in the Navigation Pane, and then click Design View.

How do I edit macros in Excel? ›

Edit the macro

On the Developer tab, in the Code group, click Macros. In the Macro name box, click the macro that you want to edit. Click Edit.

How do I turn off all macros? ›

To disable macros in Excel, follow these steps: Open Excel and click on the "File" menu Click on "Options" Select "Trust Center" from the left-hand menu Click on "Trust Center Settings" Select "Macro Settings" from the left-hand menu Select "Disable all macros with notification" or "Disable all macros without ...

How do I stop macros in Excel? ›

When you use Esc or Ctrl + Break to end the execution of the macro, you will see this window: Hit End to stop the macro from running and return to Excel. Hit Debug to go to the macro in the VBA editor window and see where the code stopped in an effort to fix the problem.

How do I unblock Excel macros? ›

Excel 2010, 2013, 2016, 2019, and Microsoft 365:
  1. Open the File: Open the Excel file containing the blocked macros.
  2. Go to the File Tab: Click on the "File" tab in the ribbon.
  3. Open Options: ...
  4. Navigate to Trust Center: ...
  5. Open Trust Center Settings: ...
  6. Navigate to Macro Settings: ...
  7. Enable Macros: ...
  8. Click OK:
Mar 19, 2023

What is the shortcut to enable macros in Excel? ›

On the Developer tab, in the Code group, click Macros. Or press the Alt + F8 shortcut. In the dialog box that shows up, select the macro of interest, and then click Run.

How to fix macro enabled Excel File? ›

How to Recover Corrupted Macro Enabled Excel File with Top 5 Ways
  1. Way 1. Use the Open and Repair Tool.
  2. Way 2. Set the Calculation Option in Excel to Manual.
  3. Way 3. Use External References to Link to the Corrupted File.
  4. Way 4. Open the Corrupted Workbook in Wordpad.
  5. Way 5. Recove macros from the Corrupted File.
May 9, 2024

How do I unblock macros from running in Excel? ›

how do I unlock a macro in excel?
  1. Open Windows File Explorer and go to the folder where you saved the file.
  2. Right-click the file and choose Properties from the context menu.
  3. At the bottom of the General tab, select the Unblock checkbox and select OK.
Apr 22, 2023

How do you stop Excel macro when it is running? ›

If you have selected to display the Running icon when a macro is running, right mouse click on the icon in the notification area to stop the macro. Or you may press the default shortcut of the Windows key plus the End key to stop the macro.

How do I stop Excel from auto starting macros? ›

In all versions of Excel, you can use a command-line switch to start Excel in safe mode. Both the /safe switch and the /automation switch can be used for this purpose. The /safe switch starts Excel in safe mode. The /automation switch disables all automatically opened files and auto-run macros.

How do I unblock macros in Access? ›

Step 1 – Launch MS Access. Click on “Options”: Step 2 – Click on “Trust Center”, then on “Trust Center Settings”, “Macro settings”, select “Enable all macros” and click OK: Step 3 – Exit MS Access.

Top Articles
10 Things To Know Before Buying A House | Chase
Paul Eugen Bleuler and the origin of the term schizophrenia (SCHIZOPRENIEGRUPPE)
Katie Pavlich Bikini Photos
Gamevault Agent
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Free Atm For Emerald Card Near Me
Craigslist Mexico Cancun
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Doby's Funeral Home Obituaries
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Select Truck Greensboro
How To Cut Eelgrass Grounded
Craigslist In Flagstaff
Shasta County Most Wanted 2022
Energy Healing Conference Utah
Testberichte zu E-Bikes & Fahrrädern von PROPHETE.
Aaa Saugus Ma Appointment
Geometry Review Quiz 5 Answer Key
Walgreens Alma School And Dynamite
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Dmv In Anoka
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Pixel Combat Unblocked
Umn Biology
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Rogold Extension
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Colin Donnell Lpsg
Teenbeautyfitness
Weekly Math Review Q4 3
Facebook Marketplace Marrero La
Nobodyhome.tv Reddit
Topos De Bolos Engraçados
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Holzer Athena Portal
Hampton In And Suites Near Me
Stoughton Commuter Rail Schedule
Bedbathandbeyond Flemington Nj
Free Carnival-themed Google Slides & PowerPoint templates
Otter Bustr
San Pedro Sula To Miami Google Flights
Selly Medaline
Latest Posts
Article information

Author: Foster Heidenreich CPA

Last Updated:

Views: 6191

Rating: 4.6 / 5 (56 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Foster Heidenreich CPA

Birthday: 1995-01-14

Address: 55021 Usha Garden, North Larisa, DE 19209

Phone: +6812240846623

Job: Corporate Healthcare Strategist

Hobby: Singing, Listening to music, Rafting, LARPing, Gardening, Quilting, Rappelling

Introduction: My name is Foster Heidenreich CPA, I am a delightful, quaint, glorious, quaint, faithful, enchanting, fine person who loves writing and wants to share my knowledge and understanding with you.