ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Date as filename (https://www.excelbanter.com/excel-programming/431436-date-filename.html)

PVANS

Date as filename
 
Hi there,

I am trying to include a a date that is referenced in a cell in my workbooks
filename. The macro crashes each time because it says it cannot include" / "
in the filename.

I have tried to change the format of the cell, the macro still takes the
date as 22/07/09.

Please can someone suggest how i can take the date listed in the cell,
remove the "/" and include it in the filename?

Thanks for all the help that this forum has provided already, I really
appreciate it.

Regards,
PVANS

Sam Wilson

Date as filename
 
dim strDate as string
strDate = format(range("A1").value,"dd.mm.yyyy")

then use strDate in your filename

"PVANS" wrote:

Hi there,

I am trying to include a a date that is referenced in a cell in my workbooks
filename. The macro crashes each time because it says it cannot include" / "
in the filename.

I have tried to change the format of the cell, the macro still takes the
date as 22/07/09.

Please can someone suggest how i can take the date listed in the cell,
remove the "/" and include it in the filename?

Thanks for all the help that this forum has provided already, I really
appreciate it.

Regards,
PVANS


Jacob Skaria

Date as filename
 
With the date in cell A1; try

strFile = Format(Range("A1"),"dd-mm-yyyy")

Then use this variable to SaveAs..

If this post helps click Yes
---------------
Jacob Skaria


"PVANS" wrote:

Hi there,

I am trying to include a a date that is referenced in a cell in my workbooks
filename. The macro crashes each time because it says it cannot include" / "
in the filename.

I have tried to change the format of the cell, the macro still takes the
date as 22/07/09.

Please can someone suggest how i can take the date listed in the cell,
remove the "/" and include it in the filename?

Thanks for all the help that this forum has provided already, I really
appreciate it.

Regards,
PVANS


PVANS

Date as filename
 
Sorry, just to clarify... I am running a macro that saves the workbook
automatically.

I am using the following code in the macro:

ActiveSheet.Copy
ActiveWorkbook.SaveAs "c:\temp\" & Range("H7")
"PVANS" wrote:

Hi there,

I am trying to include a a date that is referenced in a cell in my workbooks
filename. The macro crashes each time because it says it cannot include" / "
in the filename.

I have tried to change the format of the cell, the macro still takes the
date as 22/07/09.

Please can someone suggest how i can take the date listed in the cell,
remove the "/" and include it in the filename?

Thanks for all the help that this forum has provided already, I really
appreciate it.

Regards,
PVANS


PVANS

Date as filename
 
To Sam and Jacob,

It works beautifully. Thank you so much

You guys really have been such a great help. Thank you!

Regards,

PVANS

"Jacob Skaria" wrote:

With the date in cell A1; try

strFile = Format(Range("A1"),"dd-mm-yyyy")

Then use this variable to SaveAs..

If this post helps click Yes
---------------
Jacob Skaria


"PVANS" wrote:

Hi there,

I am trying to include a a date that is referenced in a cell in my workbooks
filename. The macro crashes each time because it says it cannot include" / "
in the filename.

I have tried to change the format of the cell, the macro still takes the
date as 22/07/09.

Please can someone suggest how i can take the date listed in the cell,
remove the "/" and include it in the filename?

Thanks for all the help that this forum has provided already, I really
appreciate it.

Regards,
PVANS



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

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