ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   save a file with current date inserted automatically (https://www.excelbanter.com/excel-programming/367756-save-file-current-date-inserted-automatically.html)

Budster

save a file with current date inserted automatically
 
I want to create macro in spreadsheet that will save the file to a specified
location using a specified name followed by the current date. Catch is I
want the current date to be inserted automatically. How is this done? may
not be able to access at work so if not a prob. post answer to
thanx in advance

MaryR

save a file with current date inserted automatically
 
Try this:

ActiveWorkbook.SaveAs FileName:= _
ActiveWorkbook.Name & "_" & DatePart("yyyy", Date) & DatePart("m", Date) &
DatePart("d", Date)

Then depending on whether you want to save as .csv or .xls, etc. you can add

FileFormat:=xlNormal
or
FileFormat:=xlCSV

and other options. You'll have to play with whether or not you need to add
the extension (like & ".xls" after the DatePart.

HTH
--
--Being powerful is like being a lady; if you have to tell people you are,
you aren''t. ~~Margaret Thatcher


"Budster" wrote:

I want to create macro in spreadsheet that will save the file to a specified
location using a specified name followed by the current date. Catch is I
want the current date to be inserted automatically. How is this done? may
not be able to access at work so if not a prob. post answer to
thanx in advance



All times are GMT +1. The time now is 01:25 PM.

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