ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Appending Filename in Macro (https://www.excelbanter.com/excel-programming/381533-re-appending-filename-macro.html)

okrob

Appending Filename in Macro
 
Assuming you want to save the original file first then make a dated
'backup'.
Here's the code:

Sub wscpy()
Dim tdate As String
tdate = Format(Date, "mm.dd.yy")
ActiveWorkbook.Save
' this saves the workbook with the old filename

Dim FN As Variant
FN = ("C:\YourPath\ISG REPORT" & " " & tdate & ".xls")
'<=== Change "YourPath" to where you save the files
If FN < False Then
ActiveWorkbook.SaveCopyAs FN
End If
End Sub


This will save your original/template and make a copy of the
entire workbook with the name ISG REPORT 01.18.07.xls

Rob




Scott wrote:
Hello,

I want to do the following in a macro:

1. Open an excel workbook called ISG REPORT.xls
2. Do some changes to this workbook
3. Resave this workbook and append the filename with the current date so
that the new (and now archived) file will be ISG REPORT 01.19.07.xls
4. This is done generally weekly.

Question? In the macrom, when saving the new file, how do I append the file
with the current date?

Thanks!

Scott




All times are GMT +1. The time now is 07:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com