Hello,

I am trying to figure out how to exit an inputbox if the password was not correct. I am calling the inputbox based on closing the useform. I want to keep users out of the workbook. They enter the correct password and they can view the workbook. If they enter the incorrect password then I just want it to message "Incorrect Password" and give them 2 more tries and then save and quit. Here is my code.... I just don't think it's the proper way to write it in the Do-Loop section. Thanks for any help!

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)

If CloseMode = 0 Then
If MsgBox("Click YES to Save & Close Excel Program!" & vbNewLine & " - OR -      " & vbNewLine & "Click NO to close this form and return to Excel!  ", 35) = 6 Then
    ThisWorkbook.Save
    Application.Quit
    Else
            
Do
    Pass = InputBox("You need to enter the password to access this page! ")
    If Pass = "8612" Then Exit Do
    If Not Pass = "8612" Then
    MsgBox "Wrong Password", vbCritical, "Error"
    End If
Loop


            Application.Visible = True
            ThisWorkbook.Save
        End If
    End If
End Sub