Home » excel » vba – Excel Copy a sheet with its code to a new xls file

vba – Excel Copy a sheet with its code to a new xls file

Posted by: admin May 14, 2020 Leave a comment

Questions:

Please, could you tell me if the following is possible in VBA:

I need to write code that copies a sheet from my workbook to a new freshly created xls file. BUT, the sheet I wanna copy has a Macro behind (it’s actually a WorkSheet_Change event handler) that I also want to copy to the new file.

Many thanks

Kind regards,

Miloud B

How to&Answers:

You can Export the code from the original and then Import it into the copy.

Here’s an article that shows some code for doing this: Macro to Add a Macro to New Workbooks