MrExcel Publishing
Your One Stop for Excel Tips & Solutions

saving excel file

Posted by Max on December 05, 2001 2:23 PM

could someone help me with the code to save an excel file with the file name being a value in a cell?


Posted by Tom Urtis on December 05, 2001 2:34 PM

Here's how

This assumes your cell of interest to be A1. Note in this example the sheet is Sheet5. This does not necessarily mean the worksheet whose tab is named "Sheet5". Look in the VBE Project Window for the exact workbook sheet name (syntax: [Sheet#(Name)]) for the worksheet with the cell value you want to save your new workbook as.

ActiveWorkbook.SaveAs ("C:\Your\File\Path\" & Sheet5.Range("A1").Value & ".xls")

Tom Urtis