Reputation: 9
Greetings one and all - a christmas puzzle for anyone still looking at this site...This works but if i decide to cancel the process (ie not save a file and stop the process at this stage) it doesn't svae the file but the following marco (filltolastrow2) is still activated how can I stop this happening?
Public Sub SaveaCopyIncomeSheet()
Dim file_name As Variant
file_name = Application.GetSaveAsFilename("Overdue Report - Draft", filefilter:="Excel Files(*.xls),*.xls")
If file_name <> False Then
ActiveWorkbook.SaveAs Filename:=file_name
MsgBox "File Saved!"
End If
filltolastrow2
End Sub
Upvotes: 0
Views: 2698
Reputation: 2827
Alternative:
Public Sub SaveaCopyIncomeSheet()
Dim file_name As Variant
file_name = Application.GetSaveAsFilename("Overdue Report - Draft", filefilter:="Excel Files(*.xls),*.xls")
If file_name = False Then GoTo E_NoFileName
ActiveWorkbook.SaveAs Filename:=file_name
MsgBox "File Saved!"
filltolastrow2
Exit Sub
E_NoFileName:
MsgBox "File Not Saved"
End Sub
Upvotes: 0
Reputation: 20054
You possibly want
If file_name <> False Then
ActiveWorkbook.SaveAs Filename:=file_name
MsgBox "File Saved!"
filltolastrow2
End If
Upvotes: 2