Password to activate macro

  • Thread starter Thread starter LB79
  • Start date Start date
L

LB79

I have a shared workbook that has a macro i want to protect. Does anyon
know of a way of doing this in either of the following ways:

1. When the macro is activated a MSGBOX asks for a password.

or

2. When the macro is activated it checks the Excel user name and if i
matches the user name in the macro it continues with the macro
otherwise it displays a not authorised message.

Thanks
 
Hi
pput the following at the beginning of your macro

sub foo()
dim ret
ret = Inputbox ("Enter your password")
if ret <> "your_password" then
msgbox "wrong password"
exit sub
end if

'your code
end sub

BUT: This kind of protection is very weak and can be easily
circumvented by a determined user
 
Fantastic!
Fortunately I am the only person in the office who knows what VB is an
how to use it.

Many thanks
 

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

Back
Top