How to move module code to another Excel for Mac workbook

This article has been archived. It is offered "as is" and will no longer be updated.
This article describes how to move Microsoft Visual Basic for Applications (VBA) code from one workbook to another.
More information
If you want to move VBA code to a different workbook, you cannot move it directly like a worksheet. Instead, you must copy the code from the module in the original workbook, and then paste the code to a module in the other workbook.

To move VBA code to a different Microsoft Excel for Mac workbook, follow these steps:
  1. Open the workbook that contains the macro module that you want to move.
  2. Open the workbook to which you want to move the code, or open a new workbook.
  3. On the Tools menu, point to Macro, and then click Visual Basic Editor.
  4. In the Project window, select the project (workbook) in which you want to put the macro module. If the Project window is not visible, click Project Explorer on the View menu.

    Note In Microsoft Excel X for Mac and later version, the Project window cannot be closed, and it is not available on the View menu.
  5. On the Insert menu, click Module.
  6. In the Project window, double-click the project that contains the existing macro.
  7. Under the project, double-click the Modules folder, and then double-click the module below to open the code window for that module.
  8. Select all of the code in the existing module and press COMMAND+C to copy it.
  9. On the Window menu, click the new module that you created in step 5. Click inside that code window, and press COMMAND+V to paste the copied code in this new module sheet.
  10. If you want to remove the original module, select the original module in the Project window; click Remove Module on the File menu, and when you are prompted, click Yes to delete the module.
  11. If there are additional modules, repeat steps 4-10 to copy, paste, and (optionally) remove those modules from the original project.
  12. On the File menu (this is the Excel menu in Excel X for Mac and later versions), click Close to return to Excel for Mac. Save both workbooks.
If a button or object is assigned to run the original macro and you have moved the code, reassign the button or object to the new macro location. To do this, hold down CONTROL, click the button or object, and then click Assign Macro on the shortcut menu. Look for the macro name and double-click that new macro location to reassign the button to that location.
XL2004 MacXLX Mac XLX XL2001 XL98 XL macro VB code program automation automated transfer copy add vba

Article ID: 288401 - Last Review: 01/12/2015 17:37:02 - Revision: 5.0

  • Microsoft Excel 2004 for Mac
  • Microsoft Excel X for Mac
  • Microsoft Excel 2001 for Mac
  • Microsoft Excel 98 for Macintosh
  • kbnosurvey kbarchive dftsdahomeportal kbinfo KB288401