How to Find and Copy a VBA Macro Module in Excel
Question details
Find the VBA module containing a macro and copy it to another workbook.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A workbook contains several standard modules, but only a few appear to contain the macros the user needs.
- Observed behavior
- Deleting a macro procedure does not automatically delete its module, so empty modules can remain in the VBA project.
Open the workbook in Excel and identify the macro name you want to find. Only enable macros from sources you trust.
Find and Export the Module Containing the Macro
Inspect the VBA project to locate the procedure, then export its standard module for use in another workbook.
In Excel, open the Visual Basic Editor from Developer > Visual Basic. If the Developer tab is not visible, enable it in Excel's ribbon settings.
In the editor, choose View > Project Explorer, expand the workbook's VBA project, and expand Modules. Double-click each module and look for the required procedure name in its code.
Right-click the module containing the procedure, select Export File, and save the standard module as a .bas file.
Open the destination workbook, select its VBA project in Project Explorer, and choose File > Import File. Select the exported .bas file.
In Excel, use File > Save As to save the destination as an Excel Macro-Enabled Workbook (.xlsm), then test the macro with trusted content enabled.

Rename or Remove Unneeded VBA Modules
Give useful modules recognizable names and remove modules only after checking their contents.
Work With Excel Spreadsheets in WPS Office
WPS Office is a free, lightweight Office alternative with a familiar interface for opening and editing spreadsheets. It supports common Excel formats for easier migration, though it does not fix Excel's VBA editor or guarantee compatibility with every macro.

Frequently Asked Questions
Why are there more modules than macros in my workbook?
Deleting a macro procedure does not automatically remove its module. In the Visual Basic Editor, expand the workbook's Modules folder and inspect each module to see what it contains.
Can I rename a VBA module?
Yes. Select the module in Project Explorer, choose View > Properties Window, and edit its (Name) property.
How do I copy a VBA module to another workbook?
Right-click the standard module in Project Explorer and select Export File. In the destination workbook's VBA project, choose File > Import File and select the exported .bas file.
Why doesn't the copied macro work in the new workbook?
It may depend on other modules, workbook objects, forms, or references that were not copied. Check those dependencies in the VBA editor and save the destination as a macro-enabled workbook.




