ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Newbie, how to save file with date and time as filename (https://www.excelbanter.com/excel-programming/386491-newbie-how-save-file-date-time-filename.html)

Michael

Newbie, how to save file with date and time as filename
 
I would like to be able to save a file with the name of the file to be the
current date and time.
Any help?

David McRitchie

Newbie, how to save file with date and time as filename
 
Hi Michael,
See backup on demand
http://www.mvps.org/dmcritchie/excel/backup.htm#demand

be sure to format so that you have year, then month, then day
so that you can quickly find the file alphabetically in the directory.
---
HTH,
David McRitchie, Microsoft MVP - Excel
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Michael" wrote in message ...
I would like to be able to save a file with the name of the file to be the
current date and time.
Any help?




Gary Keramidas

Newbie, how to save file with date and time as filename
 
one way, assuming a date is in a1 using =now()
Sub test()

Dim wb As String
Dim fPath As String
Dim dtStr As String
Dim fName As String
Dim ws As Worksheet

Set ws = Worksheets("sheet1")
wb = ThisWorkbook.Name
fPath = ThisWorkbook.Path & "\"
fName = Format(ws.Range("A1").Value, "mmddyy hhmm")
Workbooks(wb).SaveAs Filename:=fPath & fName & ".xls"
End Sub
--


Gary


"Michael" wrote in message
...
I would like to be able to save a file with the name of the file to be the
current date and time.
Any help?




Mark Dullingham

Newbie, how to save file with date and time as filename
 
Micheal,

This works for me in project i'm currently working on. You can use a command
button to activate it if you like -

CommandButton1_Click()

ActiveWorkbook.SaveCopyAs "C:\{My FolderName}\{My FileName} _
& "." & Format(Now, "dd-mmm-yyyy.hh-mm-ss") & ".xls"

End Sub

Replace the bracketed {} with your own folder and file names.

hth
Mark

"Michael" wrote:

I would like to be able to save a file with the name of the file to be the
current date and time.
Any help?


Michael

Newbie, how to save file with date and time as filename
 
Mark,
Thats cool, I got it to run as a macro without the button thing (dont get
that) but it saves a copy but not the one I am working in.
So if I am working on book1 it will save a copy with the date and time but
it will still say book1.
This might just be a small tweak to do so I thought I would ask some more.
THANKS

"Mark Dullingham" wrote:

Micheal,

This works for me in project i'm currently working on. You can use a command
button to activate it if you like -

CommandButton1_Click()

ActiveWorkbook.SaveCopyAs "C:\{My FolderName}\{My FileName} _
& "." & Format(Now, "dd-mmm-yyyy.hh-mm-ss") & ".xls"

End Sub

Replace the bracketed {} with your own folder and file names.

hth
Mark

"Michael" wrote:

I would like to be able to save a file with the name of the file to be the
current date and time.
Any help?


Michael

Newbie, how to save file with date and time as filename
 
Cool, dont get the button part but got the rest to work. Changed it to saveas
instead of copy.
THNAKS

"Mark Dullingham" wrote:

Micheal,

This works for me in project i'm currently working on. You can use a command
button to activate it if you like -

CommandButton1_Click()

ActiveWorkbook.SaveCopyAs "C:\{My FolderName}\{My FileName} _
& "." & Format(Now, "dd-mmm-yyyy.hh-mm-ss") & ".xls"

End Sub

Replace the bracketed {} with your own folder and file names.

hth
Mark

"Michael" wrote:

I would like to be able to save a file with the name of the file to be the
current date and time.
Any help?


Michael

Newbie, how to save file with date and time as filename
 
I like this better.
ActiveWorkbook.SaveCopyAs "C:\{My FolderName}\{My FileName} _
& "." & Format(Now, "yyyy-mm-dd.hh-mm-ss") & ".xls"


"Michael" wrote:

Cool, dont get the button part but got the rest to work. Changed it to saveas
instead of copy.
THNAKS

"Mark Dullingham" wrote:

Micheal,

This works for me in project i'm currently working on. You can use a command
button to activate it if you like -

CommandButton1_Click()

ActiveWorkbook.SaveCopyAs "C:\{My FolderName}\{My FileName} _
& "." & Format(Now, "dd-mmm-yyyy.hh-mm-ss") & ".xls"

End Sub

Replace the bracketed {} with your own folder and file names.

hth
Mark

"Michael" wrote:

I would like to be able to save a file with the name of the file to be the
current date and time.
Any help?



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

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