Date as filename

P

PVANS

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
 
J

Jacob Skaria

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
 
S

Sam Wilson

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

then use strDate in your filename
 
P

PVANS

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")
 
P

PVANS

To Sam and Jacob,

It works beautifully. Thank you so much

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

Regards,

PVANS
 

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

Top