ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Filename coding with date (https://www.excelbanter.com/excel-programming/378387-filename-coding-date.html)

DeanT

Filename coding with date
 
At the end of my macros, I want to save my workbook to another folder with
another name. I want to save the file AS:

C:/Mydata/testfile_yyyymmdd,xls where yyyymmdd is the current date.

How do I code this in the macro.?

Thanks for your help.

Dean

Steve Yandl

Filename coding with date
 
strFileName = "testfile_" & Format$(Date, "yyyymmdd") & ".xls"
ThisWorkbook.SaveAs "C:\Mydata\" & strFileName


Steve


"DeanT" wrote in message
...
At the end of my macros, I want to save my workbook to another folder with
another name. I want to save the file AS:

C:/Mydata/testfile_yyyymmdd,xls where yyyymmdd is the current date.

How do I code this in the macro.?

Thanks for your help.

Dean




Bob Phillips

Filename coding with date
 
Activeworkbook.SaveAs Filename:=Activeworkbook.Path & "\testfile_" &
Format(Date,"yyyymmdd") & .xls"

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"DeanT" wrote in message
...
At the end of my macros, I want to save my workbook to another folder with
another name. I want to save the file AS:

C:/Mydata/testfile_yyyymmdd,xls where yyyymmdd is the current date.

How do I code this in the macro.?

Thanks for your help.

Dean





All times are GMT +1. The time now is 05:35 PM.

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