How to save a workbook by the date and tome in a macro

  • Thread starter Thread starter madmatt
  • Start date Start date
M

madmatt

i need to save a workbook with the date and time as the filename
all in a macro so there is no user input?
any hel
 
Hi
try
sub save_date()
Dim fname
fname = "mybook" & format(now,"YYYYMMDDHHSS")
fname = fname & ".xls"
ActiveWorkbook.SaveAs Filename:=fname
end sub
 
Hi madmatt!

Note the format of the date suggested by Frank

"YYYYMMDDHHSS"

Perhaps he meant:

"YYYYMMDDHHMM" [He's had a hard day at work <vbg>]

But the advantage of this is that the files will be in date and time
order because although the series is not continuous it is in sequence
with earliest date / times first and later ones afterwards.
--
Regards
Norman Harker MVP (Excel)
Sydney, Australia
(e-mail address removed)
Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
 
Norman said:
Hi madmatt!

Note the format of the date suggested by Frank

"YYYYMMDDHHSS"

Perhaps he meant:

"YYYYMMDDHHMM" [He's had a hard day at work <vbg>]

But the advantage of this is that the files will be in date and time
order because although the series is not continuous it is in sequence
with earliest date / times first and later ones afterwards.



Hi Norman
think the whiskey is kicking in - though i meant:
"YYYYMMDDHHMMSS"

:-)
Frank
 
Hi Frank!

At last! Found someone who is using ISO8601: 2000 full non-separated
format.

The sequential advantage of YYYYMMDDHHMMSS was the precise reason why
they adopted that order rather than use a MMDDYYYY basis. A lot of
programmers had been using it for years to sort dates and times.

--
Regards
Norman Harker MVP (Excel)
Sydney, Australia
(e-mail address removed)
Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
 
Norman said:
Hi Frank!

At last! Found someone who is using ISO8601: 2000 full non-separated
format.

The sequential advantage of YYYYMMDDHHMMSS was the precise reason why
they adopted that order rather than use a MMDDYYYY basis. A lot of
programmers had been using it for years to sort dates and times.

Hi Norman
sitting most of the day next to some really big mainframe systems and
the typical HOST developer love nothing more than this kind of
timestamps for batch file processing, triggers, etc.

Frank
 

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