ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Password protect macro via a macro (https://www.excelbanter.com/excel-programming/384925-password-protect-macro-via-macro.html)

mcphc

Password protect macro via a macro
 
I know you can protect a macro by selecting Tools-VBAProject
Properties-Protection in VBA but you have to do this manually. Is it
possible to password protect a macro by running another macro?

Dave Peterson

Password protect macro via a macro
 
You could just ask for a password right at the top:

Option Explicit
sub testme
dim myPwd as string
dim pwd as string

myPwd = "topSeCrEt"

pwd = inputbox(prompt:="What's the frequency, Kenneth?")

if pwd < mypwd then
beep
exit sub
end if

'rest of code
end sub

mcphc wrote:

I know you can protect a macro by selecting Tools-VBAProject
Properties-Protection in VBA but you have to do this manually. Is it
possible to password protect a macro by running another macro?


--

Dave Peterson


All times are GMT +1. The time now is 10:02 PM.

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