How to Remove Ghost Worksheet Objects in Excel VBA
Question details
The user needs to remove hidden or ghost worksheet objects and obsolete codenames that persist in an Excel VBA project after deleting sheets.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Cleaning up a corrupted or cluttered VBA project where deleted worksheets still show up in the project explorer.
- Observed behavior
- Ghost objects cause unexpected codenames (such as CAD4) when creating new worksheets, and deleted sheets leave unusable remnants in the VBA Project Explorer.
Before attempting any of these cleanup methods, manually document your active VBA References (Tools > References) and export all essential VBA modules to your computer to prevent accidental data loss.
Strip VBA Content Using the XLSX Format
This is the most effective way to purge a workbook of corrupted or ghost VBA objects by temporarily removing all macro data.
When you save a macro-enabled workbook as a standard .xlsx file, Excel automatically strips out all VBA modules, user forms, and hidden background code. This process effectively deletes any ghost worksheets. Ensure you export your necessary code before performing this conversion.
Press Alt + F11 to open the VBA Editor. Right-click each valid module, user form, and class module in the Project Explorer, select 'Export File', and save them locally.
Go to File > Save As, and choose 'Excel Workbook (*.xlsx)' from the file format dropdown. Save and completely close the workbook.
Open the newly saved .xlsx file. Press Alt + F11 again, right-click in the Project Explorer, select 'Import File', and restore your exported modules.
Go to File > Save As, choose 'Excel Macro-Enabled Workbook (*.xlsm)', and save your cleaned file.

Transfer Valid Worksheets to a New Workbook
If the current workbook structure is deeply corrupted, moving your clean data to a brand-new file is the safest approach.
Manually Recreate Ghost Sheet Modules
Use this method if specific sheets are generating ghost codenames but you prefer not to rebuild the entire workbook.
Try WPS Office for Reliable Spreadsheet Management
Experiencing workbook corruption or ghost VBA objects in Microsoft Excel? Switch to WPS Office, a free, lightweight, and highly compatible alternative. It natively supports .xlsx and .xlsm formats, features a familiar user interface, and allows seamless migration of your macro-enabled workbooks.
- 1. Download and Install: Visit the official WPS Office website and download the free software for your operating system.
- 2. Open Your Workbook: Launch WPS Spreadsheet and open your existing Excel workbook directly.
- 3. Edit and Save: Continue editing your data and macros with full compatibility and zero format shifting.

Frequently Asked Questions
What causes ghost worksheet objects in Excel VBA?
Ghost worksheet objects usually result from minor workbook corruption when a sheet is deleted, but its associated code module or codename fails to be removed cleanly from the VBA Project Explorer.
Can I just delete the ghost module directly in the VBA editor?
No, Excel does not allow you to right-click and remove a Sheet module like you can with a standard Module. You must fix the underlying workbook structure using export/import or conversion methods to remove them.
Will saving my file as .xlsx permanently delete my macros?
Yes, the .xlsx format does not support macros and will permanently purge them. You must export your VBA code before saving as .xlsx, and then re-import it after opening the file and before saving it as a macro-enabled .xlsm file.
How do I export my VBA modules?
Open the VBA Editor by pressing Alt + F11, right-click the module you want to save in the Project Explorer, select 'Export File', and choose a location on your computer to save it as a .bas, .frm, or .cls file.




