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.
On this page8
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. Most people learn this as a sequence of clicks and forget it by next week; learning it as a pattern instead is what lets you apply it to the next, slightly different version of the problem without starting from scratch. That is the difference this page is trying to make. Treat “remove macros from 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: try it on a copy of the sheet or a handful of sample rows first and check the result before you apply it to the real data. That one habit catches almost every surprise while it is still cheap to reverse.
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. Keep this page bookmarked for the next time the same question comes up. Better still, repeat the steps once in your own workbook — doing it yourself is what turns a copied answer into something you remember. Here is the takeaway for “remove macros from excel”: follow the steps at the top, check the result on the sheet itself, and keep undo in mind while you experiment. Done once deliberately, it becomes something you do from memory in Excel rather than something you search for again.
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 “remove macros from excel” and “remove a macro from excel”. 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. “remove macros from excel”, “remove a macro from excel” all point at the one operation explained on this page, which is why they all lead here.