View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Paul B[_7_] Paul B[_7_] is offline
external usenet poster
 
Posts: 73
Default Password request to run macro

Colin, if you don't mind seeing the password when you type it in then you
can use an input box like this, if you don't want to see the password you
will need to make a user form and call it with some code

Sub Password()
Dim PW As String
PW = Application.InputBox( _
Prompt:="Please Enter The Password", _
Title:="Password Required To Run This Macro", _
Type:=2)
If PW = "mypassword" Then '****password is case sensitive ******

'''*****Your Code Here*****

Else
'''****If Password Is Incorrect*********
MsgBox Prompt:="Sorry, That Is Not The Correct Password", _
Title:="Incorrect Password", _
Buttons:=vbOKOnly

End If
End Sub

--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 97 & 2000
** remove news from my email address to reply by email **

"Colin Foster" wrote in message
...
Hi,
I have a workbook with two sheets...one visible to all and one for
maintenance. I have written two macros...one to hide the maintenance sheet
(amongst other things), the other to unhide them. They are then activated

by
clicking the relevant buttons that I have created on the face of the

visible
sheet.
What I now need to do is password protect these buttons so that if an
unauthorised user clicks on them, XL prompts for a password.
Any suggestions?
Also, although I am building the workbook in XL XP, the solution needs to
also work in '97 and 2000 if possible due to the users requirements.
Regards
Colin Foster