ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro to auto save file using the format YYMM (https://www.excelbanter.com/excel-discussion-misc-queries/47691-macro-auto-save-file-using-format-yymm.html)

Dolphinv4

Macro to auto save file using the format YYMM
 
Hi,

I recorded a macro that automatically saves a file then change the formula
in cell A1 to today's date, ie =today(), then save the file. I have a problem
with the last part...is there any way I can set the macro such that the file
will be saved as "c:\YYMM ABC" where 'YYMM' is the format of the date
(probably can be taken from cell A1) and 'ABC' is my own file name?

Thanks!

Dave Peterson

You can get the date right in the code:

dim myFileName as string
myfilename = "C:\" & format(date,"yymm") & " ABC.xls"

activeworkbook.saveas filename:=myfilename, fileformat:=xlworkbooknormal

Dolphinv4 wrote:

Hi,

I recorded a macro that automatically saves a file then change the formula
in cell A1 to today's date, ie =today(), then save the file. I have a problem
with the last part...is there any way I can set the macro such that the file
will be saved as "c:\YYMM ABC" where 'YYMM' is the format of the date
(probably can be taken from cell A1) and 'ABC' is my own file name?

Thanks!


--

Dave Peterson


All times are GMT +1. The time now is 04:55 AM.

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