+ Reply to Thread
Results 1 to 7 of 7

User Permissions VBA

  1. #1
    Registered User
    Join Date
    07-22-2008
    Location
    Leicester
    Posts
    4

    Question User Permissions VBA

    I am trying to assign user permissions to different sheets within my excel workbook.
    The way it should work is as follows:
    The file should only be accessed by 6 people.

    Sheet 1 should be accessed by Staff members A and B
    Sheet 2 should be accessed by Staff members B, C, D and E

    The way I am thinking is that the Excel file retrieves the Windows usernames of the user's and then allows them to access the file based on the requirements above.

    Can anyone please help as I am clueless.

  2. #2
    Forum Contributor wmorrison49's Avatar
    Join Date
    09-25-2007
    Posts
    267
    Here's some code that takes the Username on the computer and puts it into cell A1 on the currently open tab.

    Please Login or Register  to view this content.
    You can have this fill into any cell of course. From there, you can run something that will protect Sheet1 or Sheet2 based on what username is in that cell with a password that only you know. That would work as a way to insure that only certain people get to see the tab you want them to.
    Last edited by mudraker; 07-24-2008 at 07:43 AM.

  3. #3
    Registered User
    Join Date
    07-22-2008
    Location
    Leicester
    Posts
    4
    Quote Originally Posted by wmorrison49
    Here's some code that takes the Username on the computer and puts it into cell A1 on the currently open tab.

    Dim Name as String
    Name = Application.UserName
    Range("A1") = Name

    You can have this fill into any cell of course. From there, you can run something that will protect Sheet1 or Sheet2 based on what username is in that cell with a password that only you know. That would work as a way to insure that only certain people get to see the tab you want them to.
    Thanks for that - but the username doesn't seem to appear in the cell

  4. #4
    Forum Contributor wmorrison49's Avatar
    Join Date
    09-25-2007
    Posts
    267
    That's weird. I have attached a workbook that is working for me. Just open it up and run the ShowName macro. On my computer, "Will" pops up in A1. Hopefully this will work for you.
    Attached Files Attached Files

  5. #5
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    wmorrison49

    Please make sure in future you follow forum rules & wrap your VBA code - see rule 3 of the forum rules


    Now to the problem

    The application user name can have any type of entry in it - Include just a space and is completly independant of the Windows login ID
    Have a look at Tools > Options > General Tab > User Name

    To use the Windows Login ID
    Please Login or Register  to view this content.
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  6. #6
    Forum Contributor wmorrison49's Avatar
    Join Date
    09-25-2007
    Posts
    267
    I am a little confused. Where is the code I didn't wrap? I only put in the three lines of code on my first post.

  7. #7
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    The 3 lines of code is what you needed to wrap

    This forum has a 2 hour time limit on you be able to edit your thread/posting.
    As it was mote than 2 hours since you had posted the reply I edited your posting & wrapped the VBA code for you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1