Macro to save in a unique new name

  • Thread starter Thread starter Grady Kansas
  • Start date Start date
G

Grady Kansas

I'd like to attach a macro to a button that would save the entire
spreadsheet in a folder under a name that exists in one of the cells in
the spreadsheet (eg a nowvalue).
 
With ThisWorkbook
.SaveAs Filename:=.Worksheets("Sheet1").Range("a1").Value & ".xls", _
FileFormat:=xlNormal
End With

You may need to format that value nicely:

With ThisWorkbook
.SaveAs Filename:=Format(.Worksheets("Sheet1").Range("a1").Value, _
"yyyymmdd_hhmmss") _
& ".xls", FileFormat:=xlNormal
End With

You could add the path, too.
With ThisWorkbook
.SaveAs .path & "\" & _
Filename:=Format(.Worksheets("Sheet1").Range("a1").Value, _
"yyyymmdd_hhmmss") _
& ".xls", FileFormat:=xlNormal
End With
 
Back
Top