Try this:
Private Sub Save_Button_Click()
dim fName as variant
fName = Application.GetSaveAsFilename( _
InitialFileName:="S0000.xlsx", _
FileFilter:="Excel Workbook (*.xlsx), *.xlsx")
ActiveWorkbook.SaveAs Filename:=fName, FileFormat:=xlWorkbookDefault
End Sub
This is adapted from the example at Duplicate your workbook in seconds.
It saves the active workbook (i.e. the one currently open in the foreground of Excel). This may or may not be the workbook containing the code.
If you want to instead make sure the workbook containing this code is the one saved, change ActiveWorkbook
to ThisWorkbook
.
To trap for a filename not being provided by the user (after they delete your default one), you could add a conditional statement to check, for example like this:
Private Sub Save_Button_Click()
dim fName as variant
fName = Application.GetSaveAsFilename( _
InitialFileName:="S0000.xlsx", _
FileFilter:="Excel Workbook (*.xlsx), *.xlsx")
If fName <> False Then ActiveWorkbook.SaveAs Filename:=fName, FileFormat:= xlOpenXMLWorkbook
End Sub