View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Macro assistance

But Pete could run this, too.

Maybe surrounding the names with semicolons would help

Const arrAllowedUsers = ";Rover;Peter;Sue;Mary;"
If InStr(arrAllowedUsers, ";" & Environ("username") & ";") = 0 Then

But it isn't unusual for two people to share the same name.
Like: Joe Smith


Hansueli wrote:

Hi Rover,

You can check whether the username is in the group you want to allow to run
the macro, according to this example:

Sub YourMacro()
Const arrAllowedUsers = "Rover;Peter;Sue;Mary"
If InStr(arrAllowedUsers, Environ("username")) = 0 Then
MsgBox "You are not allowed to run this macro!", vbOKOnly + vbCritical
Exit Sub
End If
...continue with your code
End Sub

Note: the environ("username") returns the WINDOWS username from the
Win-Logon.

"Rover" wrote:

I created a macro and it works. How can I make sure only a few people can
run the macro? I have a file that goes out to 30 people for budgets inputs.
I only want my group to be able to run that particular macro, not people
outside my group.


--

Dave Peterson