Chat with us, powered by LiveChat

Export Excel Macro

How to Copy Macros in Excel 2019 EN (delete)

Macros can only be run if the file they are saved in is open. For example, if you have a macro in file A that you want to use frequently in file B, you’d have to open file A every time you want to run that macro (or save it in the personal workbook). Instead, you can save yourself some time and copy the existing macro into the file where you want to use it.

Copy Macros from Another Workbook

Macros that you create in Excel are stored in modules, and you can then copy those modules to other workbooks.

  1. Open both the file that has the saved macro and the one you wish to save it to.
  2. Click the Developer tab in either file.
  3. Click the Visual Basic button.
    Copy Macros from Another Workbook
  4. In the VBA window, the left pane displays the Project Explorer view. This shows all of the open workbooks and the modules containing macros for each file.

    Each time you open Excel and record a macro, or a number of macros, they are stored in a module. If you close out and re-open Excel, any new macros are stored in a separate module.

  5. Locate the module with the macro you want to copy. Double-click the module to open it and verify the macro is correct.
    Copy Macros from Another Workbook
  6. Click the module in the original file and drag it to the file you are copying to.
  7. The module is copied into the file.

  8. Click Save on the toolbar in the VBA window.
  9. Close the VBA program window.
    Copy Macros from Another Workbook

Test a Copied Macro

Just like when creating a macro, it’s important to test a macro you’ve copied to another workbook. If you accidentally copied the wrong one, you’ll want to fix your mistake right away.

  1. Select the sheet where you want to run the macro you’ve just copied over.
  2. Click the Macros button on the Developer tab.
  3. In the Macro dialog box, you’ll want to make sure that This Workbook is selected in the Macros menu. This is the best way to verify the macro was copied directly into the active workbook.

  4. Click the Macros in list arrow.
  5. Select This Workbook.
  6. The macro you copied into the file should appear in the list of macros for this workbook.

  7. With the macro selected, click Run.
    Test a Coped Macros

FREE Quick Reference

Click to Download