Saving file with date on it

  • Thread starter Thread starter mehta_agm
  • Start date Start date
M

mehta_agm

Hi ,
what macro do ineeed to create if i need to save my workbook with the
date mentioned on one of the cells in that rec and the filename.

for example if i have mentioned the date as 17th Jan06 on one of the
cells than i want the macro to save my file at a particular place in my
drive with the date featuring in the filename like "File011706.xls". ie
it shud automatically identify the date and save my file.

any help appreciated
Anand
 
change the location of the date, "a1" in my code and the file path, fpath in
my code. if you don't use the username\my documents location, you can remove
the uname variable


Option Explicit
Sub save_File()
Dim fPath As String
Dim FilePre As String
Dim FDate As String
Dim UName As String

UName = Environ("UserName") & "\"
fPath = "C:\Documents and Settings\" & UName & "My Documents\"
FDate = Format(Range("a1"), "mmddyy")
FilePre = "File"
ActiveWorkbook.SaveAs fPath + FilePre + FDate
End Sub
 
Hi Arnand,

Try:

'=============>>
Public Sub Tester01()

Dim sStr As String
Const sDateCell As String = "A1" '<<=== CHANGE
Const SPath As String = "C:\MyFolder\" '<<=== CHANGE

sStr = Format(Range(sDateCell), "mmddyy")
ThisWorkbook.SaveAs Filename:=SPath & "File" & sStr, _
FileFormat:=xlWorkbookNormal

End Sub
'<<=============
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top