Macro protection

  • Thread starter Thread starter Michelle
  • Start date Start date
M

Michelle

I have a program set up in excel it has a main screen with
a bunch of buttons that will take you to different area of
the workbook, what I need is to put a password or
something on the one button so that only those people who
need access to that part of the book can get into it.
 
Michelle, here is one way to require a password to run a macro

Sub Password_Request()
'you must lock the VBA project so you can't see the password in it
Dim PW As String
PW = Application.InputBox( _
Prompt:="Please Enter The Password", _
Title:="Password Required To Run This Macro", _
Type:=2)
If PW = "a123" Then 'Change password here, it is CASE sensitive

'*****Put Your Code Here*****
MsgBox "That's it !"


Else
'****If password does not match*********
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 2000 & 2003
** remove news from my email address to reply by email **
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top