tonywatsonhelp
Well-known Member
- Joined
- Feb 24, 2014
- Messages
- 3,210
- Office Version
- 365
- 2019
- 2016
- Platform
- Windows
Hi Everyone,
I have a macro that checks if a document should be closed or not,
it works great, but I get the Do you want to Save document request after it runs as you would expect, however theres never a time this document needs saving so could this macro just close the document for me without saving?
please help if you can
Tony
I have a macro that checks if a document should be closed or not,
it works great, but I get the Do you want to Save document request after it runs as you would expect, however theres never a time this document needs saving so could this macro just close the document for me without saving?
please help if you can
Tony
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
If Sheets("Welcome").Range("F1") <> "Submitted" Then
promptit = MsgBox("You have not submitted any data, closing this document will mean all Changes will be lost. Do you want to close document?", vbYesNo, "DATA NOT SENT")
If promptit = vbNo Then
Cancel = True
Exit Sub
End If
End If
Resume Next
End Sub