View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
FSt1 FSt1 is offline
external usenet poster
 
Posts: 3,942
Default automating the name of my files

hi,
Not sure what you mean by "smart, variable cell" but this code works. tested.
Sub macAutoSave()
Dim rng As String
rng = Range("D4").Value ' change to your "smart cell"
ActiveWorkbook.SaveAs Filename:=rng, _
FileFormat:=xlNormal, _
Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
End Sub

But this will also save the macro with the file.
you may just want to just save your template range.
If that is the case.....
Sub macAutoSave()
Dim rng As String
Dim rng2 as range
rng = Range("D4").Value ' change to your "smart cell"
set rng2 = Range("A1:G25") 'change to your template range
Rng2.copy
Workbooks.Add
Range("A1").PasteSpecial xlPasteAll
ActiveWorkbook.SaveAs Filename:= rng, _
FileFormat:=xlNormal, _
Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
End Sub

regards
FSt1

"Dean" wrote:

I have a template that will be reused to create hundreds of files and I'd
like some macro that would save the file with a smart name. If we assume
that the filename can be automated so it is in a particular cell - either
with or without the ".xls", whichever is easier for you - is there a macro
you can give me that would name the file according to the output of the
formula in that smart, variable, cell?

Thanks!
Dean