Remove VBA From an Excel Workbook Safely

VBA & macros · Updated November 21, 2026

To remove VBA from an Excel workbook, open it in the desktop version of Excel, choose File > Save As, and save a copy as Excel Workbook (*.xlsx). When Excel warns that VBA features cannot be saved in a macro-free workbook, choose the option to continue without those features. The new .xlsx copy will not contain the workbook’s VBA project; keep the original .xlsm or .xlsb file if you may need its macros later.

What removing VBA means

VBA is the Visual Basic for Applications code that can automate workbook tasks, respond to events such as opening a file, or provide custom functions. Excel stores VBA in macro-enabled formats such as .xlsm and .xlsb. The standard .xlsx format does not store a VBA project. Saving a copy as .xlsx is therefore the simplest way to remove the code from that copy.

Removing VBA is not the same as deleting worksheet data, formulas, formatting, or every kind of automation. It also does not remove code that is stored somewhere else, such as an Excel add-in or the Personal Macro Workbook (PERSONAL.XLSB). Those files can still make macros available in Excel even after the workbook itself is macro-free.

Think of the operation as making a macro-free version of a file, not as safely erasing every trace of the original code. If the original file matters, preserve it separately and work with a copy.

The quickest method: save a macro-free copy

  1. Open the workbook in Excel for Microsoft 365 on Windows. If a security notice appears, do not enable macros unless you trust the file and its source. You can save a copy without running its macros.
  2. Choose File > Save As. Select Browse if Excel asks where to save the file.
  3. Choose a folder and give the copy a distinct name so it is not confused with the original.
  4. In Save as type, select Excel Workbook (*.xlsx), then select Save.
  5. When Excel warns that some features cannot be saved in a macro-free workbook, choose the option to continue with the .xlsx format or remove the unsupported features. The exact wording can vary by Excel build. Do not choose an option that returns you to a macro-enabled format if your aim is to remove VBA.

Close the new file and, if useful, reopen it to check that the sheets, formulas, and important layouts are still present. Confirm the file name ends in .xlsx. The original macro-enabled file remains unchanged unless you deliberately overwrite it; avoid doing that if you need a recoverable copy.

On Mac, use File > Save As and select Excel Workbook (.xlsx) as the file format, then accept the warning about unsupported features. Labels and dialog details can differ slightly from Windows. Excel for the web can open and edit many workbooks, but it cannot run VBA or provide the full desktop Visual Basic Editor, so use desktop Excel for a deliberate removal and verification workflow.

Remove code manually before saving

Saving as .xlsx is enough to remove the VBA project from the saved copy. Manual deletion is useful when you want to inspect the project first, or when you plan to keep the file in a macro-enabled format for some other reason. It is easier to make a mistake this way, so save a backup before changing code.

In Excel for Windows, press Alt+F11 to open the Visual Basic Editor (VBE). In the editor, show Project Explorer if it is not visible, then inspect the project for the workbook. A VBA project can include standard modules, class modules, UserForms, and code attached to ThisWorkbook or individual worksheet objects. Deleting only a standard module does not remove code in those other locations.

  • For a standard module, right-click its name in Project Explorer, choose Remove [module name], and respond to the prompt about exporting it. Exporting makes a separate code file as a backup; it does not keep the code inside the workbook.
  • For a UserForm or class module, use the same Remove command if it is no longer needed. Check whether other code refers to it first.
  • For ThisWorkbook or a worksheet object, open its code window and remove the procedures you intend to delete. These objects are part of the workbook structure and generally are not removed like ordinary modules.

On Mac, open the Visual Basic Editor from Excel’s Tools > Macro menu; keyboard shortcuts can depend on the keyboard and macOS settings. The editor’s available features and layout may differ somewhat from Windows. If the goal is simply a clean macro-free deliverable, saving a copy as .xlsx is usually less error-prone than manually editing the project.

A VBA project may be password-protected. If you are authorized to edit it but cannot access the project, ask its owner for an editable copy or the password. Do not try to bypass project protection. Saving an authorized copy as .xlsx can still remove its VBA project, but it does not grant permission to access or reuse the code.

What works, and what stops working

VBA often provides actions that ordinary workbook formulas do not. Once you remove the code, a macro button may no longer perform its task, an event procedure will not run, and a custom VBA function in a cell formula may return an error or an unavailable-function result. A workbook that depends on a macro to refresh or prepare data may still open, but its automated workflow will be gone.

For example, suppose a sheet has a button that runs a procedure to copy completed rows to an archive sheet. The .xlsx copy may retain the cell values and the button’s visible shape, but it will not retain the VBA procedure that performs the copy. The button may do nothing or may still refer to a macro that is no longer available. Test essential tasks in the copy rather than assuming that a familiar-looking sheet still behaves as before.

VBA removal does not automatically rewrite formulas or replace the workbook’s logic with a different automation tool. If formulas rely on a custom VBA function, identify those cells before conversion and decide whether to replace the function with built-in Excel formulas, values, or another supported process. Save a separate copy before replacing formulas with values, because that change can remove recalculation behavior.

Buttons, controls, and other automation clues

Visible controls can be confused with VBA itself. A button may be a Form Control, an ActiveX control, or simply a shape with a macro assigned. The code and the interface are separate pieces: removing the code does not guarantee that every control will disappear or remain usable. The behavior of unsupported features can depend on the control type and the save operation, so inspect the resulting file.

  • For a Form Control button or a shape, right-click it and look for Assign Macro. If the assigned macro is being removed, the control may need to be deleted, relabeled, or given a new purpose.
  • For ActiveX controls in Windows desktop Excel, use Developer > Design Mode before selecting a control for removal. If the Developer tab is hidden, enable it through File > Options > Customize Ribbon.
  • Look for instructions, worksheet notes, or documentation that explain what a control used to do. A blank-looking button may still be important to users even if it no longer runs code.

Excel’s Macro dialog, opened with Alt+F8 on Windows, can list some runnable macros, but it is not a complete inventory of VBA. Event procedures, private routines, custom functions, and code that runs through other mechanisms may not appear there. Use the VBE project tree and workbook documentation as well when you need to understand what is being removed.

Choose the right file format

Use .xlsx when the deliverable should not contain a VBA project and does not need to retain macro functionality. Use .xlsm when the workbook must continue to store VBA. The .xlsb format is also macro-enabled, so changing an .xlsm file to .xlsb does not remove its VBA. An Excel add-in (.xlam) is a separate kind of file that can provide macros to multiple workbooks; changing one workbook to .xlsx does not remove or disable a separately installed add-in.

Saving as .xlsx may also discard other features that the format cannot store, and Excel will warn about features it cannot preserve. Read the warning rather than assuming it refers only to VBA. If the workbook contains controls, embedded objects, or other specialized content, check the converted copy carefully. If preserving a particular feature is more important than removing VBA, keep a macro-enabled version and consult the feature’s documentation before converting.

For sharing a read-only result, a PDF can preserve the visible pages, but it is not an editable spreadsheet and does not retain normal workbook functionality. For editable sharing without VBA, .xlsx is generally the appropriate choice. Keep the original macro-enabled workbook in a restricted or clearly labeled location if it is needed for maintenance.

Security and verification

Removing VBA can reduce the risk that someone runs code stored in that workbook, but it is not a complete security review. The workbook may contain external links, formulas that retrieve data, embedded content, or references to add-ins. A separate macro-enabled file elsewhere can still run if opened. Treat files from unknown sources cautiously and follow your organization’s security rules.

After saving the .xlsx copy, verify the result rather than relying only on the extension. Confirm that the file type is Excel Workbook (*.xlsx), reopen the copy, and check that expected sheets and key formulas remain. If you need stronger confirmation, try opening the Visual Basic Editor and inspect whether a VBA project is present for that workbook. Do not enable macros in the original merely to perform this check.

Editing or removing code can invalidate a VBA digital signature. A signature is not a substitute for checking the file’s source, and a signed original should not be treated as an untouched signed copy after its project is changed. If signature status matters, consult the signer or your organization’s process before modifying or distributing the file.

Common problems and how to handle them

  • The file still ends in .xlsm. Changing the name alone does not convert the format. Use Save As and select Excel Workbook (*.xlsx) in the file-type list.
  • The macro button is still visible. A visible control is not proof that the VBA remains. Check whether it has a macro assignment and decide whether the control should be removed or replaced.
  • A custom formula stops calculating. It may have depended on a VBA user-defined function. Find the affected formulas in the original and replace them with supported formulas or values only after checking the required result.
  • Excel displays a compatibility warning. Review it before continuing. The warning may cover features beyond the VBA project, and choosing .xlsx can change or discard them.
  • You cannot see all the code. The project may contain code in sheet or workbook objects, or it may be locked. Ask the owner for access rather than assuming the Macro dialog lists everything.
  • You need the original behavior later. Keep an untouched, access-controlled copy of the original macro-enabled workbook. An .xlsx copy cannot restore the removed code by changing its extension back.

Frequently Asked Questions

Does saving an Excel file as .xlsx remove VBA?
Yes. Saving a copy in the .xlsx format removes the workbook’s VBA project because .xlsx does not store VBA. Excel warns that unsupported features will be lost; keep the original macro-enabled file if you may need the code.

Can I remove macros without losing the data?
Usually, yes: Save As creates a macro-free copy while retaining ordinary worksheet data, formulas, and formatting. However, features that .xlsx cannot store may be changed or removed, so review Excel’s warning and check important sheets, controls, and formulas in the saved copy.

Will the workbook’s buttons still work after I remove VBA?
Not if their actions depended on the removed macro. A button or shape may remain visible, but it may no longer do anything. Check its assignment and either remove it, explain that it is inactive, or replace the automation with a suitable alternative.

Can I remove VBA and keep the file as .xlsm?
You can manually remove the code from the project and save the workbook as .xlsm, but that format can still store VBA, and empty or other project components may remain. If the requirement is that the delivered file contain no VBA project, saving the copy as .xlsx is the clearer method.

Does changing .xlsm to .xlsx in the filename remove macros?
No. Renaming the extension does not convert the file contents and can make the file harder to open correctly. Use Excel’s Save As command and select the .xlsx file type.

Can Excel for the web remove VBA?
Excel for the web does not run VBA and does not provide the full desktop tools for inspecting or editing VBA. Use desktop Excel to save a macro-free .xlsx copy and verify the result.

Related

Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.

More in VBA & macros

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.