ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro protection (https://www.excelbanter.com/excel-programming/311311-macro-protection.html)

Michelle

Macro protection
 
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.

Paul B[_8_]

Macro protection
 
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 **

"Michelle" wrote in message
...
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.





All times are GMT +1. The time now is 03:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com