Permissions to a macro

N

Neil Holden

I have a button in excel, i want only certain users to be able to press it,
is they any way i can add permissions to the button?

Neil.
 
K

Ken Warthen

Neil,

You could create a login userform and then use the username to determine
whether to enable or disable the command button. You could probably do the
same just using Windows username properties. I guess it depends on how large
your user base might be. I've used the login form method on several projects.

Ken
 
M

Mike H

Neil,

You could do this but it's not secure. The variable S is a comma deleted
string of allowed users. If the active user isn't in the list then the sub
terminates

Sub Button1_Click()
S = "aaa,bbb,ccc"
v = Split(S, ",")
For x = 0 To UBound(v)
If Environ("username") = v(x) Then
allowed = True
Exit For
End If
Next
If Not allowed Then Exit Sub
MsgBox "OK"
'Your Code
End Sub

Mike
 
Top