cedricthecat
Active Member
- Joined
- May 17, 2007
- Messages
- 460
Hi folks
If I use the first code below, it works without issue.
If I change the line in red, then it gives an error.
In the first code, the password is a choice of the value in cell Q2 on sheet "Words" and the password "password". In the second it's a choice of the values of Q2 or Q3 - except this doesn't work and I'm not sure why!
All help appreciated!
Non working:-
If I use the first code below, it works without issue.
If I change the line in red, then it gives an error.
In the first code, the password is a choice of the value in cell Q2 on sheet "Words" and the password "password". In the second it's a choice of the values of Q2 or Q3 - except this doesn't work and I'm not sure why!
All help appreciated!
Code:
Sub ShowWords()
ActiveWorkbook.Unprotect Password:="pass"
Application.EnableEvents = False
PassEntry.Show
[COLOR=red]If strPass <> Sheets("Words").Range("Q2") And strPass <> "password" Then[/COLOR]
MsgBox "Incorrect Password"
ThisWorkbook.Activate
Application.EnableEvents = True
Else
Sheets("Words").Visible = True
ThisWorkbook.Activate
Sheets("Words").Activate
End If
Application.EnableEvents = True
Call SheetNames
End Sub
Non working:-
Code:
Sub ShowWords()
ActiveWorkbook.Unprotect Password:="pass"
Application.EnableEvents = False
PassEntry.Show
[COLOR=red]If strPass <> Sheets("Words").Range("Q2") And strPass <> Sheets("Words").Range("Q3")Then[/COLOR]
MsgBox "Incorrect Password"
ThisWorkbook.Activate
Application.EnableEvents = True
Else
Sheets("Words").Visible = True
ThisWorkbook.Activate
Sheets("Words").Activate
End If
Application.EnableEvents = True
Call SheetNames
End Sub