Originally Posted by
SRussell
with the help of users on this forum I have created a sheet to track items of wastage in a bar environment that uses a piece of code to rename the file with a date at the end of it.
I also have macors attached to buttons in my workbook that allow me to filter certain types of data, then print the active sheet.
The question I have is when I run the code that that starts a new sheet with a new filename, my macros that I've attached to the buttons I use to run the filters/print actions don't seem to copy across into the new workbook.
How can I do this?
Hi,
Yes indeed, creating and copying into a new workbook doesn't, as you've found, copy anything from the VBE. The technique is to export the .bas module file, and import it to the new workbook, using lines of code like the ones below at the appropriate places in your macro.
Alternatively, and a technique I've used before, is to filter the data you want to present to an appropriate place, then immediately save the workbook, and then a copy of it with the new name. Now activate the copy and if there's stuff in the workbook that you don't want the recipient to get, delete it all and save again, before closing it and reopening the original master workbook if necessary. This avoids the need for exporting the .bas module
HTH
Bookmarks