Results 1 to 4 of 4

Thread: Only make a code run from an approved user list.

  1. #1
    Board Regular
    Join Date
    Dec 2013
    Location
    Portsmouth, Hampshire
    Posts
    78
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Only make a code run from an approved user list.

    Hello,
    So i have a sheet when someone clicks a button and it shows the relevant hidden cells.

    However i would like to restrict this to only approved people to have access to run this code.

    Is it possible to have a list of users in 'Settings' sheet, and once the code is activated to run it or stop the code depending on the environ("username") list?

    Thanks in advance.
    Kyle

  2. #2
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    28,228
    Post Thanks / Like
    Mentioned
    471 Post(s)
    Tagged
    47 Thread(s)

    Default Re: Only make a code run from an approved user list.

    You could use something like
    Code:
    Sub KyleJackMorrison()
       Dim Nme As String
       Dim Fnd As Range
       Nme = Environ("username ")
       Set Fnd = Sheets("Settings").Range("A1:A100").Find(Nme, , , xlWhole, , , False, , False)
       If Fnd Is Nothing Then
          MsgBox "You don't have authority"
          Exit Sub
       End If
       'your code goes here
    End Sub
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  3. #3
    Board Regular
    Join Date
    Dec 2013
    Location
    Portsmouth, Hampshire
    Posts
    78
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Only make a code run from an approved user list.

    @Fluff

    Works like a dream! Many Thanks.

  4. #4
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    28,228
    Post Thanks / Like
    Mentioned
    471 Post(s)
    Tagged
    47 Thread(s)

    Default Re: Only make a code run from an approved user list.

    You're welcome & thanks for the feedback
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •