JakeVBA2009
New Member
- Joined
- Nov 30, 2009
- Messages
- 16
Hi guys, I've got this code that i'm using to try and protect worksheets but i've got a small problem...I cant seem to make the code recognise that only 1 password will work in order to allow access to the spreadsheet.
Instead, any word thats duplicated twice on both password screens seems to let the user in so i need to make sure that only 1 certain password will allow access to the spreadsheets and anything else is barred from access. (The password used is Password)
Code is below, thanks in advance.
Sub ProtectAll()
Dim sh As Worksheet
Dim myPassword1 As String
myPassword1 = ("password")
Dim sInput1 As String
Dim sinput2 As String
sInput1 = InputBox("Enter password")
sinput2 = InputBox("Confirm password")
If sInput1 = sinput2 Then
MsgBox "User Can Type"
Else
MsgBox "User Cannot type"
For Each sh In ActiveWorkbook.Worksheets
sh.Protect Password:=myPassword1
Next sh
End If
End Sub
Instead, any word thats duplicated twice on both password screens seems to let the user in so i need to make sure that only 1 certain password will allow access to the spreadsheets and anything else is barred from access. (The password used is Password)
Code is below, thanks in advance.
Sub ProtectAll()
Dim sh As Worksheet
Dim myPassword1 As String
myPassword1 = ("password")
Dim sInput1 As String
Dim sinput2 As String
sInput1 = InputBox("Enter password")
sinput2 = InputBox("Confirm password")
If sInput1 = sinput2 Then
MsgBox "User Can Type"
Else
MsgBox "User Cannot type"
For Each sh In ActiveWorkbook.Worksheets
sh.Protect Password:=myPassword1
Next sh
End If
End Sub