View Full Version : Macro to save a file name as per a cell content.
rsdjimbie
May 5, 2009, 11:49 AM
I have a macro saving the file auto. To my desktop.
For example cell A1 = 501
I run a macro with a counter and auto. Changes A1 to 502.
Now macro must change file saving to 502, or =cell A1 content.
I also sometimes have to change destination from desktop to a specific file.
JBeaucaire
May 5, 2009, 05:02 PM
I have a macro saving the file auto. To my desktop.
For example cell A1 = 501
I run a macro with a counter and auto. Changes A1 to 502.
Now macro must change file saving to 502, or =cell A1 content.
Building on what we've done earlier, something like this should give an idea of the syntax:
Sub Save()
Dim fName As String, DTAddress As String
DTAddress = CreateObject("WScript.Shell").SpecialFolders("Desktop") & Application.PathSeparator
fName = Range("A1").Text
ActiveWorkbook.SaveAs DTAddress & fName & ".xls"
End Sub
I also sometimes have to change destination from desktop to a specific file.
Change how? Clarify your work process or desired methodology.
rsdjimbie
May 5, 2009, 11:40 PM
File save as: My documents->Renier-> Production management->May
JBeaucaire
May 6, 2009, 09:06 AM
Riddles and more riddles.
If you occasionally want to save the file to a different place and NOT use your macros normal methodology, then don't use your macro.
Click on File > Save and pick you path / filename.