ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Saving with date in filename (https://www.excelbanter.com/excel-programming/296248-saving-date-filename.html)

Ben Allen

Saving with date in filename
 
I have this code:
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\Ben Allen\My
Documents\Eurotours\Eurotours.xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

Is there a wat to make it say the current month and year after the Eurotours
bit in the name?
Thanks

--
Cheers,
Ben

Remove your.tonsils to reply
"You only live once but if you do it right once is enough!"



slc[_12_]

Saving with date in filename
 
Ben,

I got the solution from Bob Philips in one of the thread. Here is m
code which save the current active sheet into a workbook with curren
sheet name and date.

So for your case, you need to include & Format(Date, "ddmmmyy") afte
your file name and change it mmmyy.


Sub FromSheetoWorkbook()
'
' Create individual workbook from active sheet
'
Dim Fname, strMessage As String
'Save active sheet as a workbook with today's date
Fname = ActiveSheet.Name & "-" & Format(Date, "ddmmmyy")
ActiveSheet.Copy
ActiveWorkbook.SaveAs Filename:=Fname & ".xls"
ActiveWorkbook.Close SaveChanges:=False
' Display saved message
strMessage = Fname & " saved in " & vbCrLf & vbCrLf & CurDir
MsgBox strMessage, vbInformation, "File Saved!"
'
End Su

--
Message posted from http://www.ExcelForum.com


Bob Phillips[_6_]

Saving with date in filename
 
Hi Ben,

I thought we had already done this one last week?

Anyway

sFilename = "C:\Documents and Settings\Ben Allen\" & _
"My Documents\Eurotours\Eurotours" & _
Format(Date,"yyyy mm") & ".xls",

ActiveWorkbook.SaveAs Filename:= sFil;ename, _
FileFormat:=xlNormal, _
Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False

--

HTH

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

"Ben Allen" wrote in message
...
I have this code:
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\Ben Allen\My
Documents\Eurotours\Eurotours.xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

Is there a wat to make it say the current month and year after the

Eurotours
bit in the name?
Thanks

--
Cheers,
Ben

Remove your.tonsils to reply
"You only live once but if you do it right once is enough!"





Brian Baulsom

Saving with date in filename
 
Something like this :-

MyDate = Format(Date, "dd-mm-yy") ' NB. cannot use slashes
FileName = "C:\Documents and Settings\Ben Allen\My Documents\Eurotours\
" _
& "Eurotours" & " " & MyDate & ".xls"



Regards
BrianB


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


All times are GMT +1. The time now is 02:20 AM.

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