×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

how to by pass a command in VBA project

how to by pass a command in VBA project

how to by pass a command in VBA project

(OP)
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



Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close