Microsoft KB Archive/288401

= How to move module code to another Excel for Mac workbook =

Article ID: 288401

Article Last Modified on 1/31/2007

-

APPLIES TO


 * Microsoft Excel 2004 for Mac
 * Microsoft Excel X for Mac
 * Microsoft Excel 2001 for Mac
 * Microsoft Excel 98 for Macintosh

-



This article was previously published under Q288401



SUMMARY
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.
 * 1) On the Insert menu, click Module.
 * 2) In the Project window, double-click the project that contains the existing macro.
 * 3) Under the project, double-click the Modules folder, and then double-click the module below to open the code window for that module.
 * 4) Select all of the code in the existing module and press COMMAND+C to copy it.
 * 5) 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.
 * 6) 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.
 * 7) If there are additional modules, repeat steps 4-10 to copy, paste, and (optionally) remove those modules from the original project.
 * 8) 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.

Additional query words: XL2004 MacXLX Mac XLX XL2001 XL98 XL macro VB code program automation automated transfer copy add vba

Keywords: kbinfo KB288401

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.