Hi,
I have created a few mandatory fields in my excel which makes users to fill compulsorily, for that i have written a macro as below
Private Sub Workbook_Beforeclose(Cancel As Boolean)
If Application.UserName = "xxx" Then Exit Sub
If WorksheetFunction.CountA(Sheets("Customer Form").Range("C9,C10,C11,C12,c15,c17,c18,c21,C23,c25,c26,c27,c29,c30,c32,c33,c37,c39,c40,c42,D42,c44,c45,c46")) <> 24 Then
MsgBox "Workbook will not be Closed unless All required fields have been filled in!"
Cancel = True
Else
ActiveWorkbook.Close savechanges:=True
End If
End Sub
but now i want to by pass the above by the user if they want to exit the form as the users have some missing information to fill later, so i created another macro to "quit without Saving", but i dont know how to bypass the above command when they click "Quit without saving" option
Sub Quit()
MsgBox "File will be closed without saving!"
ActiveWorkbook.Close savechanges:=False
Application.Quit
End Sub
I have created a few mandatory fields in my excel which makes users to fill compulsorily, for that i have written a macro as below
Private Sub Workbook_Beforeclose(Cancel As Boolean)
If Application.UserName = "xxx" Then Exit Sub
If WorksheetFunction.CountA(Sheets("Customer Form").Range("C9,C10,C11,C12,c15,c17,c18,c21,C23,c25,c26,c27,c29,c30,c32,c33,c37,c39,c40,c42,D42,c44,c45,c46")) <> 24 Then
MsgBox "Workbook will not be Closed unless All required fields have been filled in!"
Cancel = True
Else
ActiveWorkbook.Close savechanges:=True
End If
End Sub
but now i want to by pass the above by the user if they want to exit the form as the users have some missing information to fill later, so i created another macro to "quit without Saving", but i dont know how to bypass the above command when they click "Quit without saving" option
Sub Quit()
MsgBox "File will be closed without saving!"
ActiveWorkbook.Close savechanges:=False
Application.Quit
End Sub