Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to by pass a command in VBA project

Status
Not open for further replies.

Kanandan

Technical User
Jun 13, 2021
1
IN
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



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top