VBA & Macro Problems

How to Find and Copy a VBA Macro Module in Excel

Huma Ashraf ChHuma Ashraf Ch Nov 18, 2026 870 views

Question details

Find the VBA module containing a macro and copy it to another workbook.

How to Find and Copy a VBA Macro Module in Excel
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.
Before you start

Open the workbook in Excel and identify the macro name you want to find. Only enable macros from sources you trust.

Solution 1Recommended

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.

1
Open the VBA editor

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.

2
Inspect the modules

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.

3
Export the module

Right-click the module containing the procedure, select Export File, and save the standard module as a .bas file.

4
Import it into another workbook

Open the destination workbook, select its VBA project in Project Explorer, and choose File > Import File. Select the exported .bas file.

5
Save and test the workbook

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.

Find and Export the Module Containing the Macro
Check for dependencies: A macro may rely on other modules, workbook objects, forms, or references. Exporting one module may not copy everything it needs.
Free Microsoft Office alternative

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.

Open and edit common Microsoft Excel formats, including XLSX and XLSWork with spreadsheet data in a familiar interfaceUse a free, lightweight alternative for everyday Office tasksMove existing spreadsheet files into your workflow without starting over
microsoft office alternative - wps office

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.