?? on an Archive2 post re: Save file name = contents of a cell


Posted by Lori D on September 24, 2001 5:39 AM

I have a question that I found a partial answer to in Archive2 on how to save a file using the contents of a cell as the file name. My question is, what if the contents of the cell is a date? I am getting an error that I think is due to the "\" in the date? How can I fix this? BTW - The response to the question in the archive was the following code from Alix:
Sub NameFile
Range("A1").Select
file_path = ActiveCell.Value

Thanks in advance for your help.
Range("B1").Select
ActiveWorkbook.SaveAs FileName:=file_path & ActiveCell.Value
End Sub
Cell A1 contains the filepath, B1 contains (what I want to be) the file name.

Posted by Ian on September 24, 2001 5:54 AM

not being the best (by a long way) try:

Sub NameFile

ActiveWorkbook.SaveAs ("C:\" & " " & Range("a1").Value & " " & Format((Range("b1").Value), "dd-mm-yy"))

End Sub

I'm assumig the date is B1, you can change the format of the date to whatever you need (but as you know "\" is not aloud, it's a directory break)

you'll need to change the path to where you want to save it

e.g. C:\my path\my second path

being he folder 'my second path' which can be found in the folder 'my path' on the 'C:' drive

any help??

Ian



Posted by LoriD on September 24, 2001 6:25 AM

Thanks Ian - worked great!