protect a macro

R

rbanks

I've got a workbook that email out to about 50 people each month.
have a "homepage" where I've inserted several Macro buttons an
hyperlinks.

Some of the macros, I only want available to 3 or 4 people. Can I mak
those macros where it prompts you for a password if you try to ru
them?

If so, how do I assign the password?

Thank
 
C

Chip Pearson

There isn't any built in way to password protect the execution of a macro --
you have to write the code to prompt for a password. For example,

Sub TheMacro()
If InputBox("Enter a password:") <> "the_password" Then
Exit Sub
End If
'
' rest of code
'
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
G

Gord Dibben

rbanks

Sub pass()
enterpass = InputBox("Enter Password To Run Macro")
If enterpass <> "rbanks" Then GoTo notright
MsgBox "You have got it right"
Exit Sub
notright:
MsgBox "Incorrect Password Try Again"
End Sub

Be sure to set Protection on your VBA Project so's others can't see your macro
password.

Note: there are Password crackers out there that can break the password on
your VBA Project. Excel is not secure from those who would wish to snoop but
you can keep out the casual and not-so-snoopy users.

Gord Dibben XL2002
 

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