Thread
:
Modify sub to exit if password is incorrect
View Single Post
#
2
Posted to microsoft.public.excel.programming
Don Guillett[_2_]
external usenet poster
Posts: 1,522
Modify sub to exit if password is incorrect
Try this idea
Sub passwordcheck()
pw = "yourpasswordhere"
ans = InputBox("Enter password")
If ans < pw Then
MsgBox "Wrong PW"
Exit Sub
Else
With Sheets("sheet7")
..Unprotect Password:=pw
..Range("f13") = "hello there"
..Protect Password:=pw
End With
End If
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
"Max" wrote in message
...
How could the sub below be re-expressed the other way around, ie
check the password, then exit sub immediately (with the error msg) if
password is incorrect?
Sub TestRest()
Sheet8.Select
Dim ThePassWord As String
Dim t As String
t = "What's the password"
ThePassWord = InputBox(prompt:=t)
If UCase(ThePassWord) = "BATTLEFIELD" Then
Range("D10").Value = Range("G15").Value
Else
MsgBox "That is incorrect."
End If
End Sub
Reply With Quote
Don Guillett[_2_]
View Public Profile
Find all posts by Don Guillett[_2_]