Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Excel Macro to copy and rename when workbook is saved

Posted on 2011-09-14
Medium Priority
Last Modified: 2012-05-12

I need a macro that will copy the opened workbook to a destination saved as the same filename & datetime. I need the macro to generate as soon as the workbook is saved. Any ideas?

Question by:asmyatt
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 30

Expert Comment

by:Randy Downs
ID: 36536614
Maybe this will help


... simply copying your master/template sheet (it looks like you are copying everything). This is equivilent to EDIT > "Move or Copy Sheet" > checking the "Create a copy" box

Sub CopySheet()
    Dim MySheetName As String
    MySheetName = "TestSheet"
    Sheets("MasterSheet").Copy After:=Sheets("MasterSheet")
    ActiveSheet.Name = MySheetName
End Sub

Author Comment

ID: 36536796
I need the macro to save the entire excel file to another excel file.
LVL 30

Accepted Solution

Randy Downs earned 2000 total points
ID: 36536980
Try this. You may need to close your file before copying though.


Dim SrceFile
Dim DestFile

SrceFile = "g:\jerry\export.zip"
DestFile = "c:\data\zippedfiles\export.zip"
FileCopy SrceFile, DestFile

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Cancel future meetings from user mailboxes in Office 365 using Remove-CalendarEvents
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question