Reputation: 65
Sub Autosave()
ActiveWorkbook.SaveAs Filename:="C:\Users\PC\Desktop\NAME.xlsm" _
, FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
End Sub
In the above code I was trying to change the file name "NAME" to value of range "A1" , however it throws an error always. Is there any way to solve this.
Upvotes: 0
Views: 72
Reputation: 12499
To SaveAs Value of range "A1"
Sub Autosave()
Dim FileName As String
FileName = Sheets("Sheet1").Range("A1").Text
ActiveWorkbook.SaveAs FileName:="C:\Users\PC\Desktop\" & FileName _
, FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
End Sub
Upvotes: 1