Macro Filename as Date

D

Donkin

I have the following Macro, which saves the file to the entry in Cell
AG13.

The Cell AG13 is formatted as a date and I would like to use the macro
but cannot format the filename as a date, when I try it saves as
“False.xls”

Range("ag13").Select

savename = ActiveCell.Value & ".xls "

ActiveWorkbook.SaveAs Filename:= _
"C:\" & savename, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False



Any help would be appreciated.
 
F

FastOneBaz

You can't have "/" in your filename and since these are likely to be i
your date you can't have them.


If your date is in cell B4, you could try this:



FileName = Range("B4").value

FileName = replace(Filename,"/","")

activeworkbook.saveas filename & ".xls
 
N

Norie

How is the date formatted in the cell?

If it has any /'s in it then it may not be valid as a filename.

You could try something like this.

Code
 

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