save as cell reference


Posted by Bernadette on December 11, 2001 4:55 AM

could u tell me the code for a macro that saves a workbook with the name of a cell in the workbook?
uve probably been asked this a million times before, but id be great full for any help

Posted by Dank on December 11, 2001 5:16 AM

Say your file name is in cell A1 of the current sheet.

Activeworkbook.SaveAs "C:\Any Folder\" & Range("A1").value & ".xls"

Regards,
Daniel.



Posted by Colo on December 11, 2001 5:16 AM

Hi Bernadette

Sub Test()
Dim MyPath As String, MyRange As Range
MyPath = ThisWorkbook.Path
Set MyRange = Sheets(1).Range("A1") 'with the name of a cell
ThisWorkbook.SaveAs Filename:=MyPath & "\" & MyRange.Value & ".xls"
End Sub