ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Insert Todays Date - 3 in file name (https://www.excelbanter.com/excel-programming/302412-insert-todays-date-3-file-name.html)

Hargrove[_2_]

Insert Todays Date - 3 in file name
 
I have the following code which save a file from one directory to another and adds the date with each save:

ChDir "I:\EXLDATA\BatchTracking"
Workbooks.Open Filename:="I:\EXLDATA\BatchTracking\AttyPlace.xls"
ChDir "I:\EXLDATA\ATTYMGMT\Batch Tracking"
ActiveWorkbook.SaveAs Filename:= _
"I:\EXLDATA\ATTYMGMT\Batch Tracking\AttyPlace" & _
Format(Date, "yyyy-mm-dd") & ".xls", FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWindow.Close
End Sub

I run the file on Monday, but would like it to save with Friday's date. Would it be possible to do something like TodaysDate - 3, or Date, "yyyy-mm-dd - 3"?

Bob Phillips[_6_]

Insert Todays Date - 3 in file name
 
If you just want 3 days ago use

Format(Date-3, "yyyy-mm-dd")

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Hargrove" wrote in message
...
I have the following code which save a file from one directory to another

and adds the date with each save:

ChDir "I:\EXLDATA\BatchTracking"
Workbooks.Open Filename:="I:\EXLDATA\BatchTracking\AttyPlace.xls"
ChDir "I:\EXLDATA\ATTYMGMT\Batch Tracking"
ActiveWorkbook.SaveAs Filename:= _
"I:\EXLDATA\ATTYMGMT\Batch Tracking\AttyPlace" & _
Format(Date, "yyyy-mm-dd") & ".xls", FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWindow.Close
End Sub

I run the file on Monday, but would like it to save with Friday's date.

Would it be possible to do something like TodaysDate - 3, or Date,
"yyyy-mm-dd - 3"?




All times are GMT +1. The time now is 10:17 AM.

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