ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Permissions to a macro (https://www.excelbanter.com/excel-programming/433558-permissions-macro.html)

Neil Holden

Permissions to a macro
 
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.

Ken Warthen[_2_]

Permissions to a macro
 
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

"Neil Holden" wrote:

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.


Mike H

Permissions to a macro
 
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

"Neil Holden" wrote:

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.



All times are GMT +1. The time now is 12:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com