I have a spreadsheet that runs a series of macros, that lets a user import data, clean and reformat the data, then SaveAs another file name. I don't want to ever overwrite the original file.
I am using this code to try to SaveAs another name, but sometimes the original file is still getting saved. Is there a good way to ensure that my original file never get overwritten once the macros have started?
I am using this code to try to SaveAs another name, but sometimes the original file is still getting saved. Is there a good way to ensure that my original file never get overwritten once the macros have started?
VBA Code:
Sub SaveAsAnotherFile()
Application.DisplayAlerts = False
TodayDate = Format(Date, "yyyy-mm-dd")
NewFileName = TodayDate & " Quotation " & Range("E1") & " - " & Range("B6") & " - " & Range("A11")
FileSaveAsName = Application.GetSaveAsFilename(NewFileName, filefilter:="Excel Files (*.xlsm), *.xlsm")
If FileSaveAsName = "False" Then
Do
MsgBox "Please save this as another file before continuing...", vbOKOnly
FileName = Application.GetSaveAsFilename(NewFileName, filefilter:="Excel Files (*.xlsm), *.xlsm")
Loop Until FileName <> "False"
End If
ActiveWorkbook.SaveAs FileName:=FileSaveAsName, FileFormat:=52
Application.DisplayAlerts = True
End Sub