?
Solved

Excel Macro to copy and rename when workbook is saved

Posted on 2011-09-14
3
Medium Priority
?
275 Views
Last Modified: 2012-05-12
Experts,

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?

Thanks.
0
Comment
Question by:asmyatt
[X]
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
3 Comments
 
LVL 30

Expert Comment

by:Randy Downs
ID: 36536614
Maybe this will help

http://www.ozgrid.com/forum/showthread.php?t=61914&page=1


... 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



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

Author Comment

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

Accepted Solution

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

http://www.dbforums.com/microsoft-excel/1609243-how-copy-file-excel-vba.html

Dim SrceFile
Dim DestFile

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

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

800 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