Saving Excel File with Name and Date Details

July 20, 2009 by vba excel
Filed under: Excel Tips 
Sponsor

Excel Tips Saving Excel File with Name and Date Details [Q]
I need excel tips to save Microsoft excel file I am working on (template) with the name of
the file and the date?

ex. “filename - 2008-10-29.xls”

also, if the name is duplicated, add a number to the end numerically

ex. “filename - 2008-10-29-01.xls”

Excel Tips Saving Excel File with Name and Date Details [A]

You can follow this excel tips to creates microsoft excel files in the
following format if already in the same path

filename - 2008-10-29.xls
filename - 2008-10-29(1).xls
filename - 2008-10-29(2).xls

etc…..

Dim myPath As String, myFile As String, myExt As String, mySerial As
String

mySerial = “”
myPath = “C:\Test\”
myFile = “filename” & ” - ” & Format(Date,”YYYY-MM-DD”)
myExt = “.xls”

‘ create output using sequence 1 to n if file already exists
If Len(Dir(myPath & myFile & mySerial & myExt)) > 0 Then

Do While Len(Dir(myPath & myFile & mySerial & myExt)) > 0
mySerial = “(” & Val(Mid(mySerial, 2)) + 1 & “)”
Loop

End If

ActiveWorkbook.SaveAs Filename:=myPath & myFile & mySerial & myExt

  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google
  • E-mail this story to a friend!
  • Live
  • MisterWong
  • Propeller
  • StumbleUpon
  • Technorati
  • TwitThis
  • YahooMyWeb
  • Print this article!

Rate This Tips:

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...


Incoming excel search terms

excel file save date formula,name of day excel date 2008,save excel file with date,append date to filename in excel macro,dim mypath as string myfile as string myext as string myserial as string,excel file details,excel file save date,excel save date formula,vba open filename previous day date,auto append filename excel with date,automatic date excel file name,automatic naming of excel files,automatically include date in excel file name,date created excel,details about a file in excel,details of excel sheet,excel date of file,excel file date function,excel macro auto save different filename,excel macros save as days date,excel save date,excel save filename date,excel thisworkbook saveas mypath & myfile,excel vba add date time to filename,excel vba auto saveas filename date,excel vba filename date,excel vba saving a file as the name in a cell,how to add the date to the name of an excel file when saving,how to save a excel file using a filename based on date?,naming excel files,save an excel file under an automatic name,save excel as date,save file previous business day excel macro,saving a spreadsheet and appending the date to the filename,saving excel files,saving excel files with date,tips on naming excel files,vba excel save filename date time,vba save file to include date,,0,0h,1,2h,3,access vba save file name date,add a date to the file name while saving in net,add date and time in filename vba excel,add date and time to excel filename,add date to cell when saving vba



Related Excel Tips

Comments

Have another excel answer or questions for this problem ?
Feel free to post it here..