Password protected macro

B

Beverly Darvill

Is there a way to password protect a macro.

The workbook it will run in is already password protected but I don't want
other users (they open it in Read Only with on the Administrators opening it
full mode) inadvertantly clicking the macro although it won't cause any
problem if they do just will stop them from viewing the workbook for about 5
mins dependant on the number of worksheets the macro has to update.

Thanks
 
S

Simon Lloyd

You can put a line of code or two just before your main code, somethin
like

If environ("username")<> "Simon" O
environ("username")<> "Bob" Then Exit Su

Now if the windows logon name is not equal to Simon or Bob the sub wil
exit everytime
Is there a way to password protect a macro

The workbook it will run in is already password protected but I don'
wan
other users (they open it in Read Only with on the Administrator
opening i
full mode) inadvertantly clicking the macro although it won't cause an
problem if they do just will stop them from viewing the workbook fo
about
mins dependant on the number of worksheets the macro has to update

Thank

--
Simon Lloy

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com
 
G

Gary Brown

Wrong post...AND sorry for SHOUTING :O<
--
Hope this helps.
If it does, please click the Yes button.
Thanks in advance for your feedback.
Gary Brown
 
C

Chip Pearson

If environ("username")<> "Simon" Or
environ("username")<> "Bob" Then Exit Sub


You need an AND not an OR.

If Environ("username") <> "Simon" And _
Environ("username") <> "Bob" Then Exit Sub

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 

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