Protect macro for unauthorised use

J

Johan_vl2431

How can I protect a macro so that you need to give a password before you can
run the macro?
Once the file is closed the macro protection should automatically be
protected.

Thank you in advance!
 
J

Jim Rech

One way is to ask for the password right in the macro.

Sub PassExample()
Dim PW As String
PW = InputBox("Password please", "Password to Run Macro")
If PW = "pass" Then
MsgBox "Running macro"
Else
MsgBox "Sorry"
End If
End Sub


--
Jim
| How can I protect a macro so that you need to give a password before you
can
| run the macro?
| Once the file is closed the macro protection should automatically be
| protected.
|
| Thank you in advance!
|
 
Top