In Excel: The reliable way is File ▸ Save As ▸ Excel Workbook (.xlsx): that format cannot hold VBA, so Excel strips every macro as it saves.
VBA macro: Remove Macros from a Workbook
Sub RemoveModulesFromOtherWorkbook()
Dim target As Workbook
Dim vbComps As Object
Dim i As Long
' Keep this Sub in PERSONAL.XLSB and point it at the OPEN workbook to strip.
Set target = Workbooks("Report.xlsm")
If target Is ThisWorkbook Then
MsgBox "Run this from a different workbook — a module cannot delete itself.", vbCritical
Exit Sub
End If
Set vbComps = target.VBProject.VBComponents
For i = vbComps.Count To 1 Step -1
If vbComps(i).Type = 1 Then vbComps.Remove vbComps(i) ' 1 = standard module
Next i
MsgBox "Standard modules removed from " & target.Name, vbInformation
End SubRun this from PERSONAL.XLSB (or any workbook other than the target) — a standard module that deletes the component it is currently executing from crashes Excel, which is why the Sub refuses to run against ThisWorkbook. It also needs Trust Center ▸ Macro Settings ▸ "Trust access to the VBA project object model" ticked, and it removes standard modules only: event code in sheet objects and ThisWorkbook survives, because those components cannot be removed, only emptied.
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.
Work on a copy — removal is not undoable and the code cannot be recovered afterwards.
To strip everything: File ▸ Save As, choose Excel Workbook (.xlsx), and accept the "VBA project will be lost" warning.
To remove selectively: press Alt + F11 and expand the workbook, then Modules, in the Project Explorer.
Right-click each unwanted module and choose Remove, answering No to the export prompt unless you want a .bas backup.
Open ThisWorkbook and every sheet object and delete any event code there as text — those components cannot be removed, only emptied.
What this does
Stripping macros out of a workbook is usually wanted for one of two reasons — a file is triggering security warnings you would rather it did not, or you are handing data to someone who should not receive the code with it. The blunt method is also the most thorough: save the file as .xlsx. That format has no container for VBA, so Excel discards the whole project during the save, warns you once, and hands back a clean file. Nothing survives, including event handlers. When the workbook must stay macro-enabled and only certain code should go, remove components individually in the editor: Alt + F11, right-click the module in the Project Explorer, and choose Remove — decline the export prompt unless you want a backup .bas file. Modules and userforms can be removed outright; sheet objects and ThisWorkbook cannot, so any event code inside those has to be selected and deleted as text. The same idea underpins a lot of everyday Excel work, so the few minutes spent getting it right here pay back across every sheet you build afterwards. Treat it as a pattern, not a one-off, and it stops being something you look up and starts being something you reach for. Treat “delete macros in excel” as a small repeatable workflow rather than a one-off click you hope to remember next time. Use a small test block before the live file, so any surprise in the affected cells shows up while it is still harmless. 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. That turns a workflow that saves repeating the same clicks every week into a method you can reuse, explain, and defend when the workbook leaves your screen.
A worked example
A monthly report workbook carries an old refresh macro nobody uses, and every recipient sees a security warning because of it. If the file no longer needs any automation, open it, choose File ▸ Save As, pick Excel Workbook (.xlsx), and accept the warning that VBA features will be lost — the copy that lands on disk is macro-free and opens without a bar. If instead one macro must go while others stay, press Alt + F11, expand Modules, right-click Module2, choose Remove Module2, and answer No to "Do you want to export before removing?". Then open ThisWorkbook and the sheet objects and check for event code, which is easy to miss because those entries look empty in the tree whether or not they contain anything. Removing macros is mostly a distribution problem: a workbook that is meant to be data should not travel as code, and a file that trips security warnings will get quarantined or ignored. Saving to .xlsx solves it in one move; the editor route exists for when part of the automation still has to survive. A practical tip before you scale it up: build it once on a small block of test data, confirm the number against the tool on this page, and only then point it at your real sheet. That one habit catches almost every mistake while it is still cheap to fix, long before a wrong figure reaches a report or a colleague.
In Google Sheets
If you are in Google Sheets rather than Excel, the good news is that the formula shown here is identical and the workflow barely changes — menus sit across the top instead of in a ribbon, and a few function names differ slightly, but anything you build here moves across with little or no rework. 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, the tool proves it, and the detail above shows why it holds — so the next time a colleague asks, you can answer without reaching for search. The short version of “delete macros in excel”: the answer is at the top of this page, the tool proves it on your own numbers, and the sections above explain why it holds so the next variation does not stump you. Excel rewards people who reference cells instead of typing values and who keep inputs separate from formulas, because that is what makes a result you can audit months later. Build it once, deliberately, with the live tool as a check, and you convert a one-off lookup into a reusable skill — which is the whole point of learning the why and not just the what.
Common mistakes
- Assuming .xlsx is macro-free because it opens without a warning, without checking. It is genuinely free of VBA — but the check people actually skip is whether the .xlsm original still exists somewhere and is the copy being circulated.
- Deleting modules but leaving event handlers behind. Workbook_Open and Worksheet_Change live in ThisWorkbook and the sheet objects, which stay in the tree after every module is gone, so the file remains macro-enabled and still prompts.
- Running a module-deleting macro from inside the workbook it is stripping. A standard module that removes the component it is currently executing from takes Excel down with it — keep Sub RemoveModulesFromOtherWorkbook() in PERSONAL.XLSB and point it at the target, which is why the Sub above refuses to run against ThisWorkbook.
- Expecting that Sub to work with default settings. Editing the VBA project from VBA requires "Trust access to the VBA project object model", which is off by default and deliberately so.
- Running any removal on the only copy of the file. There is no undo and no version of the code left in the workbook — export the modules first if there is any chance they are wanted again.
Frequently asked questions
What is the fastest way to remove every macro?
Save As ▸ Excel Workbook (.xlsx). The format cannot store VBA, so the save discards the entire project in one step, including event code that manual removal usually misses.
Can I delete just one macro and keep the rest?
Yes. Alt + F11, open the module holding it, select the Sub from its Sub line to End Sub, and delete the text. Remove the whole module only if nothing else is in it.
The workbook still shows a security warning after I removed the modules — why?
Something is left in ThisWorkbook or a sheet object. Those components always exist and cannot be removed from the tree, so their code has to be deleted as text. Saving as .xlsx settles it either way.
Can I get a removed macro back?
Only from a backup, an exported .bas file, or a previous version in OneDrive or SharePoint. Removal inside the editor is immediate and Ctrl + Z does not reach it.
Other ways people ask this
On the way here you may have searched this as “delete macros in excel”, “delete a macro in excel”, “how do you delete a macro in excel” and “how to delete a macro in excel” — it is all the same task, and this page is the single, complete answer to it.
Why do people search for this in so many different ways?
Because the same task has many names. “delete macros in excel”, “delete a macro in excel”, “how do you delete a macro in excel” all point at the one operation explained on this page, which is why they all lead here.