Consulting

Results 1 to 3 of 3

Thread: Adding message and loop to input box password

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Smile Adding message and loop to input box password

    I'm trying to add a message box if an invalid password has been entered into the below, but keep getting a runtime error, any ideas on how to fix this?

    Runtime Error 13
    Type Mismatch

    Thanks



    Private Sub Workbook_Open()
    Do
    pword = InputBox("Please Enter Password")
    If pword = ThisWorkbook.Sheets("Passwords").Range("B4").Value Then
        Statement = True
        Sheet3.Visible = True
        Sheet3.Unprotect ("blue")
        Sheet3.Select
    
    
    ElseIf pword = ThisWorkbook.Sheets("Passwords").Range("B5").Value Then
        Statement = True
        Sheet4.Visible = True
        Sheet4.Unprotect ("yellow")
        Sheet4.Select
        
    ElseIf pword = ThisWorkbook.Sheets("Passwords").Range("B6").Value Then
        Statement = True
        Sheet5.Visible = True
        Sheet5.Unprotect ("red")
        Sheet5.Select
        
    ElseIf pword = ThisWorkbook.Sheets("Passwords").Range("B3").Value Then
        Statement = True
        Sheet3.Visible = True
        Sheet3.Unprotect ("blue")
        Sheet4.Visible = True
        Sheet4.Unprotect ("yellow")
        Sheet5.Visible = True
        Sheet5.Unprotect ("red")
        Sheet1.Visible = True
        Sheet1.Unprotect ("admin")
        Sheet1.Select
    ElseIf pword <> ThisWorkbook.Sheets("Passwords").Range("B:B").Value Then
    MsgBox "Incorrect Password Entered. Please Try Again"
    End If
    Loop Until Statement = True
    End Sub
    Last edited by freetimefost; 01-22-2020 at 01:29 PM. Reason: Fixed the loop issue

Tags for this Thread

Posting Permissions

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