In Excel: Open File ▸ Options ▸ Trust Center ▸ Trust Center Settings ▸ Macro Settings, choose "Disable VBA macros with notification", then reopen the file and click Enable Content on the yellow bar. Excel for the web cannot create, run, or edit VBA macros. Open the workbook in the Excel desktop app to work with macros.
On this page8
VBA macro: Enable Macros in Excel
Sub CheckMacrosEnabled()
Dim msg As String
msg = "Macros are enabled in this session." & vbCrLf & _
"Excel version: " & Application.Version & vbCrLf & _
"Workbook: " & ThisWorkbook.Name
MsgBox msg, vbInformation, "Macro Check"
End SubNothing enables macros from inside VBA — the setting lives in the Trust Center, outside the code. This Sub is a probe instead: if the dialog appears, macros are running; if nothing happens, they are still blocked.
How to run this macro
- Press Alt + F11 to open the VBA editor.
- Insert > Module.
- Paste the code above.
- Press
F5, or close the editor and run it from Developer > Macros. - Save the file as .xlsm so the macro is kept.
Close the workbook, then right-click the file in Windows Explorer, open Properties, tick Unblock, and click OK — skip this only if the file never came from email or a download.
Open Excel and go to File ▸ Options ▸ Trust Center ▸ Trust Center Settings ▸ Macro Settings.
Select "Disable VBA macros with notification" — this is the safe default that still lets you approve a file per workbook.
Optionally add the folder you keep your macro workbooks in under Trusted Locations, so files there open without a prompt.
Reopen the workbook and click Enable Content on the yellow bar.
What this does
Excel ships with VBA macros switched off, and it stays that way until you make a deliberate choice in the Trust Center. There are two separate blocks people run into, and they need different fixes. The first is the ordinary security prompt: a yellow bar reading "Macros have been disabled" appears under the ribbon, and one click on Enable Content lets the file run for good. The second is Mark of the Web — for a workbook downloaded from the internet or received as an email attachment, newer builds of Excel show a red bar instead, with no Enable button at all. That bar cannot be dismissed from inside Excel; you have to right-click the file in Windows Explorer, open Properties, tick Unblock at the bottom of the General tab, and then reopen it. The Trust Center setting governs the yellow bar; the Unblock checkbox governs the red one. A macro runs in the desktop app's VBA environment, not in the cell grid: the workbook has to be saved in a macro-enabled format such as .xlsm to keep the code, and your macro security settings — or a file that arrived from the internet — can block it until you trust it. Excel for the web cannot run VBA at all. The difference between a quick fix and a sheet you can trust is the extra minute you spend validating “enabling vba in excel”. Start on a copy or a tiny sample, keep the affected cells visible, and compare the result with the outcome you expected before you touch the real workbook. When this is a ribbon command, the selection matters more than the button: confirm the range, apply the command, then spot-check the output before saving. The point is a workflow that saves repeating the same clicks every week, but the practical win is that someone else can open the file and understand what happened without asking you.
A worked example
A colleague emails you a reporting workbook. You open it, the red "blocked" bar appears, and none of the buttons on the sheet do anything. Save the attachment to your Documents folder first — macros can never run from the temporary attachment folder. Right-click the saved .xlsm file, choose Properties, tick Unblock, and click OK. Reopen it in Excel and the bar turns yellow; click Enable Content once and the workbook is trusted permanently on that machine. To confirm the macros really are live, paste Sub CheckMacrosEnabled() into a module and press F5 — a dialog naming your Excel version means everything downstream will run. Enabling macros is the first gate every automation runs into: a workbook full of correct VBA does nothing at all while the setting is off, and the symptom — buttons that do not respond, no error message — looks like broken code rather than blocked code. Getting the Trust Center and the Unblock checkbox right once saves diagnosing the same non-bug on every new file that arrives. If the macro will be shared, add a comment at the top saying what it changes and which sheet it expects, and keep the workbook as .xlsm — saving it as .xlsx removes the code.
In Google Sheets
Google Sheets does not run VBA. A macro written for Excel has to be rewritten in Google Apps Script (Extensions ▸ Apps Script), and an .xlsm file converted to Sheets keeps its cells but drops the code. The aim was to get you unstuck fast and leave you a little more capable than a copy-paste would. The answer is at the top and the detail above shows why it holds — so the next time a colleague asks, you can answer without reaching for search. For “enabling vba in excel”, the checks are about the environment as much as the code: desktop Excel with macros enabled for this file, a macro-enabled workbook and a saved copy to fall back on. Run it once on test data, compare the result with what the code says it does, and only then run it on the real sheet.
Common mistakes
- Choosing "Enable all VBA macros" as a permanent setting. It silences the prompt but also removes the one warning you get before a hostile file executes. "Disable with notification" plus Enable Content per workbook gives the same convenience with the protection intact.
- Fighting the red Mark-of-the-Web bar from inside Excel. No Trust Center setting removes it — the block is a property of the file on disk, so it only clears via right-click ▸ Properties ▸ Unblock, or by placing the file in a Trusted Location.
- Enabling macros but saving the file as .xlsx. That format cannot hold VBA at all, so the code is silently discarded on save and the workbook comes back empty of macros next time. Use .xlsm.
- Running the file straight from the email attachment preview. Excel opens attachments in a protected temporary folder where macros never execute; save the file somewhere real first.
Frequently asked questions
How do I enable macros for just one workbook instead of all of them?
Leave Macro Settings on "Disable VBA macros with notification" and click Enable Content on the yellow bar when that specific file opens. Excel remembers the decision for that workbook on that computer and stops asking.
Why is there no Enable Content button on my security bar?
The bar is red, not yellow — that is Mark of the Web, applied to files from the internet or email. Close Excel, right-click the file, choose Properties, tick Unblock on the General tab, click OK, and reopen it.
What is a macro-enabled workbook?
It is the .xlsm file format (or .xlsb for the binary variant, and .xltm for templates). Only these formats store VBA code. Saving a workbook with macros as plain .xlsx deletes the code, and Excel warns you once before it does.
Can my IT department block this?
Yes. Group Policy can lock Macro Settings so the Trust Center options are greyed out, and it can block macros in files from the internet outright. If the options will not change, that policy is why — ask IT for a Trusted Location instead.