Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Modify sub to exit if password is incorrect

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,522
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Modify sub to exit if password is incorrect

Many thanks, Don. Your idea was illustrative, and I was able to apply it
successfully.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Autoshut Excel if password is incorrect Ed Excel Discussion (Misc queries) 12 December 28th 06 11:01 PM
PASSWORD REMOVAL I have the password to open the file and the password to modify the file now how to remove them LJ[_4_] Excel Programming 0 April 27th 06 03:18 AM
VBA password request upon exit ken4capitola Excel Programming 2 November 17th 05 08:34 AM
VBA Project Password prompt on Exit Malcolm Makin Excel Programming 2 April 22nd 05 10:59 PM
Excel asks for addin password on exit Karl Excel Programming 2 November 21st 04 12:17 PM


All times are GMT +1. The time now is 10:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"