File save with macro, pick the file name from named cell on spreadsheet


Posted by Nils on April 21, 2000 11:02 AM

I'm trying to create a sub function in visual basic ( or a macro) that uses the content in a named cell as the name of the file. Is there a technic for doing this. I tried to create a macro to do "File, Save as"
and then edit the code to prompt me for a file name. Could not get that to work either.
Thanks
Nils

Posted by Tom Morales on April 21, 2000 11:10 AM

Nils - if your desired file name is in range A1, this will do it:

Sub filenamer()
kname = Range("A1").Formula
ActiveWorkbook.SaveAs FileName:=kname
End Sub

Tom



Posted by Nils on April 21, 2000 11:25 AM

Re: File save with macro..... Thank you Tom it works perfectly.

Thank You, it works perfectly
Nils