Copy workbook, don't copy macro

  • Thread starter Thread starter CongroGrey
  • Start date Start date
C

CongroGrey

Is it possible to copy a workbook but not the macro?

Backround - I have created a workbook which receives transferspreadsheet
data from Access. I have an Excel macro which formats the sheet, then
deletes the transferspreadsheet sheet. I want the user to be able to save
this report with the current date, but not copy the macro to the new sheet.

Is this possible?
 
Add code to your macro to move the formatted sheet into a new workbook,
change the MyNewWorkbook.xls to the name you want the new file to have and
the FormattedSheet.xls name to the name of the workbook that contains the
macro:

Application.Workbooks.Add
ActiveWorkbook.SaveAs "MyNewWorkbook.xls"
Application.Workbooks("FormattedSheet.xls").Sheets(1).Activate
Sheets(1).Activate
ActiveSheet.Move Before:=Workbooks("MyNewWorkbook.xls").Sheets(1)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top