Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Save As file name + Today's Date using a macro

Please could someone tell me how to use a macro to Save a worksheet as the
filename + the date and then save it as it's previous name again. This is
to create a backup copy of the spreadsheet and then let the user work on the
previous spreadsheet from it's original filename. I am pretty sure this has
got to be in VBA. Here is the code I have found to save as filename+Date:

Private Sub SaveDatabaseButton_Click()
ActiveWorkbook.SaveAs Filename:= _
€œF:\User Form for Lessons Learned\Lessons Learned € _
& Format(Date, €œyyyymmdd €œ) & Format(Time, €œhh.mm.ss€) & €œ.xls€, _
FileFormat:=xlNormal, Password:=€", WriteResPassword:=€",
ReadOnlyRecommended:=False _
, CreateBackup:=False
End Sub

But because I am totally new to VBA I can't even get that to work!!! So i
really need someone to tell me exactly to get from start to finish (finish
being a point where I have a macro that will do what I have explained above).

If anyone can help I will be very very grateful. Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Save As file name + Today's Date using a macro

Here is what I did on one of my macros. I needed it to save with the
current date and also save as it was:

Sub test()

ActiveWorkbook.SaveAs Filename:= _
"F:\User Form for Lessons Learned\Lessons Learned " &
Format(Now(), "mm-dd-yyyy") & ".xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=False

ActiveWorkbook.SaveAs Filename:= _
"F:\User Form for Lessons Learned\Lessons Learned.xls",
FileFormat:= _
xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=False

End Sub

I hope that helps.
roryt wrote:
Please could someone tell me how to use a macro to Save a worksheet as the
filename + the date and then save it as it's previous name again. This is
to create a backup copy of the spreadsheet and then let the user work on the
previous spreadsheet from it's original filename. I am pretty sure this has
got to be in VBA. Here is the code I have found to save as filename+Date:

Private Sub SaveDatabaseButton_Click()
ActiveWorkbook.SaveAs Filename:= _
"F:\User Form for Lessons Learned\Lessons Learned " _
& Format(Date, "yyyymmdd ") & Format(Time, "hh.mm.ss") & ".xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=False
End Sub

But because I am totally new to VBA I can't even get that to work!!! So i
really need someone to tell me exactly to get from start to finish (finish
being a point where I have a macro that will do what I have explained above).

If anyone can help I will be very very grateful. Thanks


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,311
Default Save As file name + Today's Date using a macro

You should just be able to save the file first, and then resave to the name
with the date. Just add this before the 'SaveAs' line.
ActiveWorkbook.Save


HTH,
Paul


"roryt" wrote in message
...
Please could someone tell me how to use a macro to Save a worksheet as the
filename + the date and then save it as it's previous name again. This
is
to create a backup copy of the spreadsheet and then let the user work on
the
previous spreadsheet from it's original filename. I am pretty sure this
has
got to be in VBA. Here is the code I have found to save as
filename+Date:

Private Sub SaveDatabaseButton_Click()
ActiveWorkbook.SaveAs Filename:= _
"F:\User Form for Lessons Learned\Lessons Learned " _
& Format(Date, "yyyymmdd ") & Format(Time, "hh.mm.ss") & ".xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=False
End Sub

But because I am totally new to VBA I can't even get that to work!!! So
i
really need someone to tell me exactly to get from start to finish (finish
being a point where I have a macro that will do what I have explained
above).

If anyone can help I will be very very grateful. Thanks



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 318
Default Save As file name + Today's Date using a macro

What is the error you are getting in the Macro?

"roryt" wrote:

Please could someone tell me how to use a macro to Save a worksheet as the
filename + the date and then save it as it's previous name again. This is
to create a backup copy of the spreadsheet and then let the user work on the
previous spreadsheet from it's original filename. I am pretty sure this has
got to be in VBA. Here is the code I have found to save as filename+Date:

Private Sub SaveDatabaseButton_Click()
ActiveWorkbook.SaveAs Filename:= _
€œF:\User Form for Lessons Learned\Lessons Learned € _
& Format(Date, €œyyyymmdd €œ) & Format(Time, €œhh.mm.ss€) & €œ.xls€, _
FileFormat:=xlNormal, Password:=€", WriteResPassword:=€",
ReadOnlyRecommended:=False _
, CreateBackup:=False
End Sub

But because I am totally new to VBA I can't even get that to work!!! So i
really need someone to tell me exactly to get from start to finish (finish
being a point where I have a macro that will do what I have explained above).

If anyone can help I will be very very grateful. Thanks

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Save As file name + Today's Date using a macro

With ActiveWorkbook
.SaveAs Filename:="F:\User Form for Lessons Learned\Lessons Learned " &
_
Format(Now, "yyyymmdd hh.mm.ss") & ".xls"
.SaveCopyAs "C:\TEMP\XXXX.XLS"
End With


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"roryt" wrote in message
...
Please could someone tell me how to use a macro to Save a worksheet as the
filename + the date and then save it as it's previous name again. This

is
to create a backup copy of the spreadsheet and then let the user work on

the
previous spreadsheet from it's original filename. I am pretty sure this

has
got to be in VBA. Here is the code I have found to save as

filename+Date:

Private Sub SaveDatabaseButton_Click()
ActiveWorkbook.SaveAs Filename:= _
"F:\User Form for Lessons Learned\Lessons Learned " _
& Format(Date, "yyyymmdd ") & Format(Time, "hh.mm.ss") & ".xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=False
End Sub

But because I am totally new to VBA I can't even get that to work!!! So

i
really need someone to tell me exactly to get from start to finish (finish
being a point where I have a macro that will do what I have explained

above).

If anyone can help I will be very very grateful. Thanks





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Save As file name + Today's Date using a macro

One of the benefits of saving a filename with a date is being able to sort
by date.
It is, therefore, preferable to save with the format yyyymmdd or a variation
thereof.


wrote in message
ups.com...
Here is what I did on one of my macros. I needed it to save with the
current date and also save as it was:

Sub test()

ActiveWorkbook.SaveAs Filename:= _
"F:\User Form for Lessons Learned\Lessons Learned " &
Format(Now(), "mm-dd-yyyy") & ".xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=False

ActiveWorkbook.SaveAs Filename:= _
"F:\User Form for Lessons Learned\Lessons Learned.xls",
FileFormat:= _
xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=False

End Sub

I hope that helps.
roryt wrote:
Please could someone tell me how to use a macro to Save a worksheet as
the
filename + the date and then save it as it's previous name again. This
is
to create a backup copy of the spreadsheet and then let the user work on
the
previous spreadsheet from it's original filename. I am pretty sure this
has
got to be in VBA. Here is the code I have found to save as
filename+Date:

Private Sub SaveDatabaseButton_Click()
ActiveWorkbook.SaveAs Filename:= _
"F:\User Form for Lessons Learned\Lessons Learned " _
& Format(Date, "yyyymmdd ") & Format(Time, "hh.mm.ss") & ".xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=False
End Sub

But because I am totally new to VBA I can't even get that to work!!! So
i
really need someone to tell me exactly to get from start to finish
(finish
being a point where I have a macro that will do what I have explained
above).

If anyone can help I will be very very grateful. Thanks




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading File Name in VB Macro that contains today's date dhstein Excel Discussion (Misc queries) 10 November 13th 08 02:48 AM
Save spreadsheet into folder based on today's Date? nbaj2k[_27_] Excel Programming 4 August 7th 06 01:59 PM
Macro to save Excel file with date and time in the file name? sonic_d_hog Excel Programming 2 January 5th 06 05:57 PM
Save Workbook (Blist) as today's date teresa Excel Programming 1 December 5th 04 10:37 PM
Export a file with today's date Grek Excel Programming 5 April 30th 04 11:24 AM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"