If an Excel workbook was saved as .xlsx, its VBA project was removed because that file format cannot store VBA macros. If it is still a macro-capable file such as .xlsm or .xlsb, the project may be hidden, blocked, damaged, or genuinely missing; check the file type and available backups before trying recovery.
First confirm the workbook’s file type
The extension is the quickest clue. In File Explorer, check the name at the end of the file; if extensions are hidden, turn on File name extensions in the View menu. In Excel, use File > Info to inspect the workbook, or choose File > Save As and look at the selected file type without saving over the original.
- .xlsx: A standard Excel workbook that does not store VBA projects. Saving a macro-enabled workbook in this format prompts a warning that macros will be removed. If you confirmed that warning, the saved .xlsx copy no longer contains the VBA project.
- .xlsm: A macro-enabled Excel workbook format that can store VBA.
- .xlsb: An Excel binary workbook format that can also store VBA.
- .xls: The older Excel workbook format, which can contain macros, although it has other compatibility limitations.
- .xltm: A macro-enabled Excel template format.
Changing the extension of an .xlsx file to .xlsm does not bring code back. It only changes the name, not the contents. If the workbook was saved as .xlsx, recovery means finding an earlier copy or another source for the VBA code.
What it means for a VBA project to be missing
A VBA project is the container for a workbook’s Visual Basic for Applications code. It can include standard modules, code attached to worksheets and workbook events, class modules, and UserForms. Excel stores the project inside the workbook file. A workbook can therefore still display all its sheets, formulas, formatting, and data even when its VBA project has been removed.
That is why a workbook that looks normal is not proof that its macros remain. Conversely, a macro that does not run is not proof that the project is gone. Excel may be blocking macros for security reasons, the project may be locked for viewing, or the code may rely on a missing library or another file. Those problems call for different fixes from restoring a deleted project.
Also distinguish VBA from other Excel features. Formulas, Power Query queries, and Office Scripts are not VBA projects. A workbook can retain those features while losing VBA, or have no VBA at all despite containing complex automation.
Check whether the project is hidden or merely unavailable
Open the file in desktop Excel for Microsoft 365 on Windows, then press Alt+F11 to open the Visual Basic Editor. If the editor opens, use View > Project Explorer, or press Ctrl+R, to show the project list. Look for an entry such as VBAProject (WorkbookName.xlsm) and expand it. A project with modules or worksheet objects is present, even if its code is not immediately visible.
If you use a Mac, open the Visual Basic Editor from the Developer tab; keyboard shortcuts can differ depending on the keyboard and function-key settings. Excel for the web does not run or edit VBA code, so use the desktop app to inspect the project. Opening a workbook in the browser and seeing no macro controls is not, by itself, evidence that the project was deleted.
- If Project Explorer is closed, show it from the View menu.
- If the project is listed but will not expand or view, it may be protected with a project password. That is different from an empty project.
- If no project appears, verify that you opened the intended workbook, not a similarly named export, preview, or copy.
- If the code is present but a macro will not run, check whether Excel has blocked it before concluding that it is missing.
Common reasons a project disappears
The most common cause is saving a macro-enabled workbook as .xlsx. Excel warns that VBA cannot be saved in that format. If someone chooses to continue, the resulting workbook keeps ordinary spreadsheet content but discards the VBA project. A later rename to .xlsm cannot reverse that operation.
Other possibilities include working from the wrong copy, receiving an exported workbook from another person or system, or using a backup created after the project was removed. A damaged file can also behave unexpectedly, although file corruption should not be assumed simply because a macro fails. In some cases, the VBA project is still there but inaccessible because it is password-protected or because Excel is preventing macros from running.
Messages matter. A notice that macros are disabled points to security settings or file trust, not necessarily missing code. A message about a missing library or reference usually means code exists but depends on a component Excel cannot locate. A locked project message indicates restricted viewing. An absent project in the Visual Basic Editor, combined with an .xlsx extension, is much stronger evidence that the project was removed from that copy.
Recover the project from an earlier version
If the project is truly absent, the safest recovery is to locate a copy made before it disappeared. Do not overwrite the current file while searching. Save a separate copy of the workbook first, and keep the original unchanged in case it contains useful data or evidence about what happened.
- Check version history. If the file is stored on OneDrive or SharePoint, open it in Excel and look for File > Info > Version History. Choose a version from before the suspected conversion or deletion, then open or restore it carefully. Availability depends on the storage service and account settings.
- Look for an earlier local copy. Check the folder, email attachments, shared drives, and any backup system used by your organization. Search for versions with .xlsm, .xlsb, .xls, or .xltm extensions, rather than relying only on the workbook’s current name.
- Check Excel’s recovery options. In desktop Excel for Windows, go to File > Info > Manage Workbook and look for recovered or unsaved versions. These options may help after an unexpected closure, but they cannot guarantee recovery of a project already removed and saved over.
- Ask the code’s owner. If the workbook came from a colleague, vendor, or internal team, ask for the original macro-enabled file or the exported source modules. They may have a maintained copy of the code.
If you find an earlier macro-enabled file, open it in desktop Excel and confirm that the project appears in the Visual Basic Editor. Compare its sheets and data with the current workbook before deciding which version to use. A recovered file may contain older data, while the latest .xlsx may contain newer changes. You may need to transfer data between copies rather than simply replace one with the other.
Can the code be rebuilt from the current workbook?
If no earlier copy or source code exists, Excel does not provide a command that reconstructs a removed VBA project from the workbook’s remaining cells. The code must be recovered from another source or recreated. Start by documenting what the macros did: buttons, menu items, workbook-open actions, generated reports, and any instructions users followed can provide useful clues.
Check whether the project’s author kept exported files. In the Visual Basic Editor, modules can be exported as .bas files, class modules as .cls files, and forms as .frm files, often with an associated .frx file. Those files can be imported into a macro-enabled workbook, but they need to come from a trustworthy source and may require supporting references or other components. Do not treat unfamiliar downloaded code as safe merely because it is presented as a recovery file.
Rebuilding can take more work than restoring a backup. Event code may depend on exact worksheet names, named ranges, workbook structure, or other files. A macro that appears simple may also contain business rules that are not obvious from its buttons or output. If the workbook supports a business process, have the code reviewed and test it on copies before putting it back into use.
Security, passwords, and macro warnings
Excel may block VBA because macros can make changes to files, access data, or perform other actions. A yellow security warning or a message that macros have been blocked is not the same as a missing project. Only enable macros when you trust the file and its source. Avoid lowering security settings globally just to make one workbook run; follow your organization’s security policy instead.
A password-protected VBA project can be present but unavailable for viewing. If it belongs to you or your organization, request the password or an unlocked source copy from the person responsible for it. Do not assume that password protection means the project is corrupt, and do not use unknown utilities that promise to bypass protection. They can put the workbook or its data at risk.
Changing VBA code can invalidate a digital signature on the project. If the workbook relies on a signature to establish trust, ask its publisher or administrator for a properly signed version after any repair. Keep an untouched original and test any recovered file in a controlled location before sharing or using it with important data.
Prevent the same loss next time
Keep macro-enabled workbooks in a format that supports VBA, such as .xlsm or .xlsb, and pay attention to Excel’s warning when changing formats. Use a descriptive filename that includes the file type or purpose, and store a separate backup before making major edits. For team files, version history can help, but it is not a substitute for a deliberate backup and a copy of the source code.
- Maintain a clean, known-good macro-enabled master file.
- Export important modules and forms as source files, and store them with appropriate access controls.
- Record what the macros do, what they depend on, and who maintains them.
- Test format changes on a duplicate and reopen the saved copy to confirm the VBA project remains present.
- Use desktop Excel for VBA work; Excel for the web is not a VBA editor or runtime.
Frequently Asked Questions
Can I get VBA back after saving the workbook as .xlsx?
If that .xlsx copy was saved after Excel removed the project, the code is not recoverable from that copy through a normal Excel command. Find a prior .xlsm, .xlsb, or other macro-enabled version, or obtain the source code from its author.
Why does Alt+F11 show no VBA project?
First make sure you opened the correct file and that Project Explorer is visible. Then check the extension. If the workbook is .xlsx, its VBA project cannot be stored there; if it is a macro-enabled file, look for a protected project or another copy before assuming the file is damaged.
Can macros be disabled even when the project is still there?
Yes. Excel security settings can prevent code from running while the project remains in the file. Inspect it in the desktop Visual Basic Editor and treat security warnings separately from a missing-project diagnosis.
Does Excel for the web remove VBA?
Excel for the web does not run or edit VBA. Use desktop Excel to inspect and maintain the code, and avoid converting a macro-enabled file to a format that does not support VBA.
Can a password-protected project be recovered?
A locked project may still be present, but Excel will not let you view its code without authorized access. Ask the owner or administrator for the password or an accessible source copy rather than trying to bypass the protection.
Related
- table() in RStudio: How It Counts and Displays Data
- Data Validation and Reconciliation in Excel Explained
- PowerPoint Table Diagonal Split Cell: Practical Methods
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- VBA Change Pivot Table Source: Code and TipsTo change a PivotTable’s source with VBA, create a PivotCache for the new worksheet range or Excel table,…
- Macro Recorder for Mac: Record and Run Excel MacrosIn Excel for Mac, turn on the Developer tab, choose Developer > Record Macro, perform the steps you…
- Add Controls to a VBA UserForm: Steps and CodeTo add controls to a VBA UserForm, open the form in the Visual Basic Editor and drag a…
- Excel VBA: Find a Cell with Specific Text in a RangeTo find a cell containing specific text with Excel VBA, use the Range.Find method. Set options such as…
- Excel VBA: Check If AutoFilter Is Active on a SheetIn Excel VBA, check Worksheet.AutoFilterMode to find out whether AutoFilter arrows are displayed, and check Worksheet.FilterMode to find…
- Macro Recorder for Games: How It Works and What to KnowA macro recorder for games captures a sequence of keyboard or mouse inputs and replays them, often with…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.