+ Reply to Thread
Results 1 to 2 of 2

Cancel Inputbox if Password string incorrect

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-03-2012
    Location
    Washington State
    MS-Off Ver
    Excel 365
    Posts
    340

    Cancel Inputbox if Password string incorrect

    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

  2. #2
    Forum Contributor
    Join Date
    04-03-2012
    Location
    Washington State
    MS-Off Ver
    Excel 365
    Posts
    340

    Re: Cancel Inputbox if Password string incorrect

    Anyone have a suggestion? Thanks in advance!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1