Password protect macro via a macro

G

Guest

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?
 
D

Dave Peterson

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
 

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

Top