ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Protect macro for unauthorised use (https://www.excelbanter.com/excel-discussion-misc-queries/141380-protect-macro-unauthorised-use.html)

Johan_vl2431

Protect macro for unauthorised use
 
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!


Jim Rech

Protect macro for unauthorised use
 
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
"Johan_vl2431" wrote in message
...
| 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!
|



Johan_vl2431

Protect macro for unauthorised use
 
Thank you!




All times are GMT +1. The time now is 08:56 PM.

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