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. Keep the inputs visible and clearly labelled and the whole thing stays auditable — anyone who opens the file later, including you, can see at a glance exactly what feeds the result and change one assumption without hunting through the formula. For “remove a macro in excel”, the reliable version is a short checking loop, not just the first command that appears to work. Run it on a deliberately small range first, watch how the affected cells change, and only then apply the same setup to the full sheet. 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 is what makes a workflow that saves repeating the same clicks every week useful in real work: repeatable, auditable, and not dependent on memory or luck.
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
Everything above works in Google Sheets too. Excel and Sheets share the formula syntax used here; only the surrounding menus are arranged differently. That portability is deliberate — learn it once and it follows you between the two tools and across Windows and Mac. Keep this page bookmarked for the next time the same question comes up. Better still, rebuild the example once in your own sheet — doing it yourself, with the tool above to check against, is what turns a copied formula into a technique you own. Treat “remove a macro in excel” as a small building block rather than a chore. Once the inputs sit in their own cells and the formula reads from them, the same setup answers a dozen related questions with a tweak, and Excel keeps every dependent figure current as the data changes. The tool above is there so you can rehearse and verify before committing anything to a real workbook; the steps and worked example are there so the logic sticks. Get it right once and it stops costing you time — it starts saving it, every time the question comes back around.
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
This is also commonly searched as “how to remove macros in excel” and “excel remove macros”. They describe the identical operation, so you are in the right place no matter how you phrased it.
Why do people search for this in so many different ways?
Because the same task has many names. “how to remove macros in excel”, “excel remove macros” all point at the one operation explained on this page, which is why they all lead here.