Save file name = contents of a cell


Posted by John on August 01, 2001 11:51 AM

Any ideas on how to save a file using the contents of a cell as the file name? What if the cell is in a workbook that is a copy of an original workbook?

Posted by Alix on August 02, 2001 6:02 AM

Hi John


OK
This code will specify both the filepath and file name dependent on entries in cells A1 (e.g. C:\MyFiles\ ) and B1 (e.g. MyFile Number One).

Sub NameFile

Range("A1").Select
file_path = ActiveCell.Value
Range("B1").Select
ActiveWorkbook.SaveAs FileName:=file_path & ActiveCell.Value
End Sub

This would save the current workbook as C:\MyFiles\MyFile Number One.xls

Hope this helps
Alix



Posted by John on August 02, 2001 11:41 AM

Alex,

That's what I needed, and the added bonus is the ability to name a directory.
Thank you very much.