permissions for running macros

G

Guest

I'm very new to macros and am using Excel 2003. I have written a macro to
protect only certain worksheets within my workbook, however I do not want
everybody being able to run this macro. How do I put security on this macro
so only certain individuals have the ability to execute it?
 
G

Guest

1.- Go to the visual basic editor.
2.- To the left theres a list in Bold "VBA Project (name of your workbook),
right click it
3.- Choose VBA Projet properties
4.- Click the Protection Option
5.- Enable "Lock Project from Viewing" and put some password on it

Thats it, next time you enter you wont be able to view your macros without
the password
 
G

Guest

Thank-you but I am not too worried about people being able to view the
properties of a macro, I am worried about people running the macro.

The steps per your instructions disable anybody from viewing the properties
of a macro which is great but the option to run the macro is still there and
when I tried to run it I was able to run it without having to enter that
password that I used for protecting the properties of it. Is there a way so
that when you click on run that it asks for a password before running it?
 
P

Paul B

Charlene, here is one way,

Sub PassWord_To_Run()
'must lock VBA project so you can't see the password in it

Dim MyStr1 As String, MyStr2 As String
With ActiveSheet
MyStr2 = ("123") 'This is the password and it is CASE sensitive
MyStr1 = InputBox("Password Is Required To Run this Macro ")
If MyStr1 = MyStr2 Then

'your code here

Else
MsgBox ("Access Denied")
End If
End With
End Sub
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003
 
R

Roger Whitehead

Or write the code in a Private Sub. It can then only be run from the VBE.

HTH
Roger
Shaftesbury (UK)
 
G

Gord Dibben

A Private Sub will not show in Tools>Macro>Macros but can be run just by typing
the name in and "Run"

Assuming the user knows the macro name, of course.


Gord Dibben MS Excel MVP
 

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

Similar Threads


Top