wadergirl
New Member
- Joined
- Jun 3, 2016
- Messages
- 49
I have a macro-enabled workbook that I'm using as a template.
When the user is done filling in new info daily, they click on a form button at the top that runs this macro, saving the modified workbook as a .xlsx (so the template doesn't get mucked up).
Unfortunately, if the user cancels out of the dialog box instead of saving, the code just continues to the second line, closing the template without saving and losing all of the data that was input.
I've tried using
but of course the code does not like the commas in the If statement.
Same with
I feel like this should be so obvious, but I must be missing something.
When the user is done filling in new info daily, they click on a form button at the top that runs this macro, saving the modified workbook as a .xlsx (so the template doesn't get mucked up).
VBA Code:
Sub SaveClose()
Application.Dialogs(xlDialogSaveAs).Show , sFilename, xlWorkbookDefault 'User defines filename - should be Daily mmddyy.xlsx
Workbooks("Template w formulas.xlsm").Close SaveChanges:=False 'Closes this workbook without saving
End Sub
Unfortunately, if the user cancels out of the dialog box instead of saving, the code just continues to the second line, closing the template without saving and losing all of the data that was input.
I've tried using
VBA Code:
If Application.Dialogs(xlDialogSaveAs).Show , sFilename, xlWorkbookDefault = False Then Exit Sub
Same with
VBA Code:
Dim x
x = Application.Dialogs(xlDialogSaveAs).Show , sFilename, xlWorkbookDefault
If x = False Then Exit Sub
I feel like this should be so obvious, but I must be missing something.