![]() |
Saving file with date on it
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 -- mehta_agm ------------------------------------------------------------------------ mehta_agm's Profile: http://www.excelforum.com/member.php...o&userid=30518 View this thread: http://www.excelforum.com/showthread...hreadid=502358 |
Saving file with date on it
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 -- Gary "mehta_agm" wrote in message ... 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 -- mehta_agm ------------------------------------------------------------------------ mehta_agm's Profile: http://www.excelforum.com/member.php...o&userid=30518 View this thread: http://www.excelforum.com/showthread...hreadid=502358 |
Saving file with date on it
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 '<<============= --- Regards, Norman "mehta_agm" wrote in message ... 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 -- mehta_agm ------------------------------------------------------------------------ mehta_agm's Profile: http://www.excelforum.com/member.php...o&userid=30518 View this thread: http://www.excelforum.com/showthread...hreadid=502358 |
All times are GMT +1. The time now is 06:33 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com