There is a better way than the method suggested by Arshad.
If you want to move VBA code to a different workbook, you cannot move it directly like a worksheet. Instead, you can export the code modules and userforms from the original workbook as files, and then import the code into the other workbook.
To move VBA code to a different Microsoft Excel for Mac workbook, follow these steps:
- Open the workbook that contains the macro module that you want to move (source workbook).
- Open the workbook to which you want to move the code (destination workbook), or open a new workbook (destination workbook).
- In the VB Editor of the source workbook, in the Project window, select the module or userform you wish to move.
- In the VB Editor of the source workbook, from the File menu choose **Export File...**and then name and save the .bas file.
- Switch to the destination workbook.
- In the VB Editor of the destination workbook, on the File menu, choose Import File... and the open the saved .bas file you exported from the source workbook.
- Your module or userform will now be in the destination workbook.