+ Reply to Thread
Results 1 to 15 of 15

Multiple passwords for different users. Access restricted to certain worksheet

  1. #1
    Forum Contributor
    Join Date
    03-09-2012
    Location
    Isle of Man
    MS-Off Ver
    Excel 2010
    Posts
    118

    Multiple passwords for different users. Access restricted to certain worksheet

    Hi Folks,

    I hoping you can help me. I'm looking to allow access to colleagues to a spreadsheet with multiple worksheets. Each colleague would have their own tab that may contain personal information about them and also a summary tab with certain information on all employees that isn't sensitive.

    I would like people to have to login to the workbook and depending on the user and password get access to their worksheet and view a summary sheet. I can't use the sheet I need to as it holds personal data on it but I have attached an alternative. It's a holiday chart with the same premise. Each user has their own tab and the information is collated into an overall holiday view so the principle is the same.

    I've been doing some research and viewed a number of posts where a user list would be maintained in another tab that would only be viewable to the Admin user. VBA code would unlock/lock the various tabs depending on which user accesses the workbook.

    If someone was able to help advise me on what code to use and how to install it I would be grateful.

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Multiple passwords for different users. Access restricted to certain worksheet

    I have a similar set up to this (in a workbook I don't have access to right at this moment) but rather than messing around with passwords, it's all based on network username.
    A workbook open event determines the username and displays the relevant sheet for that user. This is based on a list maintained by an Admin user.

    Sheets that are not relevant to that user are hidden away using VeryHidden so a user cannot easily just unhide them.

    Be wary though, Excel is not massively secure. Anyone with a little skill, the desire to poke around where they shouldn't and a spare 5 minutes could strip password protection from a workbook and access the VBA enabling them to unhide sheets.

    To test if this is possible for you, press Alt+F11 to open the VB Editor, press Ctrl+G to open the Immediate Window (this usually appears at the bottom of the VBE). In that window type msgbox environ$("username") and press return. A box should show up and reveal your login ID.

    BSB

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: Multiple passwords for different users. Access restricted to certain worksheet

    To re-iterate what BSB has said, Excel is not a secure environment. It would take only a matter of minutes to make all the worksheets visible, even if the VBA Progect is password protected. Therefore, if you hold IDs and passwords on a worksheet within the workbook, they will be visible, as will all the data. And if you test Network Login IDs and hold them within the code, that is a non trivial maintenance task.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Contributor
    Join Date
    03-09-2012
    Location
    Isle of Man
    MS-Off Ver
    Excel 2010
    Posts
    118

    Re: Multiple passwords for different users. Access restricted to certain worksheet

    Yes, that does come up with my Login ID

  5. #5
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Multiple passwords for different users. Access restricted to certain worksheet

    OK, although I highly do not recommend attempting to store very sensitive data in a workbook that you want other people to use you can do it and below is one quick and easy way.

    1) Create a new workbook with Sheet1 being the summary sheet you mentioned - For the code below I've called this sheet "Summary"
    2) Create another sheet to store the User IDs in column A and associated sheet name in column B
    UserID1 - Mary
    UserID2 - Mungo
    UserID3 - Midge
    UserID4 - Etc etc etc

    3) Add each of the named sheets
    4) Press Alt+F11 to open the VB Editor and double click where it says "ThisWorkbook" somewhere near top left.
    5) Paste the code below into the code window
    6) Save and close the file
    7) Try opening the file as the Admin and as a non Admin user and see if it works.

    Please Login or Register  to view this content.
    NOTE: This is untested. All off the top of my head.
    NOTE 2: I take no responsibility for any sensitive information that is obtained by persons not entitled.

    BSB
    Last edited by BadlySpelledBuoy; 05-27-2016 at 07:20 AM.

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: Multiple passwords for different users. Access restricted to certain worksheet

    You also need a Before_Close event handler to hide sheets before closing.

    Otherwise, you can open the workbook without enabling macros and you'll see someone else's worksheet/data.

  7. #7
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Multiple passwords for different users. Access restricted to certain worksheet

    Good catch. I missed that because my system at work doesn't ask before enabling macros.

    The below also goes in the code window for "ThisWorkbook"

    BSB

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    03-09-2012
    Location
    Isle of Man
    MS-Off Ver
    Excel 2010
    Posts
    118

    Re: Multiple passwords for different users. Access restricted to certain worksheet

    Hey, thanks for your help guys.

    However when I run the following code I get the error:

    Compile Error:
    Block If without End IF
    Please Login or Register  to view this content.

  9. #9
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Multiple passwords for different users. Access restricted to certain worksheet

    Sorry, my bad! Told you it wasn't tested.

    Move the end if line to after next I and before application.screenupdating = true.

    BSB

  10. #10
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Multiple passwords for different users. Access restricted to certain worksheet

    If you are interested, here's something else worth looking into...

    http://www.excelforum.com/excel-new-...passwords.html
    HTH
    Regards, Jeff

  11. #11
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Multiple passwords for different users. Access restricted to certain worksheet

    Attached is a file that I created to control access to sheets.

    The current usernames and (case sensitive) passwords are listed on the first sheet only for demo purposes.
    User's can change their password (unknown to administrator) and access their page(s).
    Administrators (anyone whose username begins with "admin") can reset passwords to their default and change which sheets a user can access.
    Attached Files Attached Files
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  12. #12
    Forum Contributor
    Join Date
    03-09-2012
    Location
    Isle of Man
    MS-Off Ver
    Excel 2010
    Posts
    118

    Re: Multiple passwords for different users. Access restricted to certain worksheet

    Thanks

    Now I get a Next without For compile error

  13. #13
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Multiple passwords for different users. Access restricted to certain worksheet

    Could you post your current code and show which line it errors on?

    BSB

  14. #14
    Forum Contributor
    Join Date
    03-09-2012
    Location
    Isle of Man
    MS-Off Ver
    Excel 2010
    Posts
    118

    Re: Multiple passwords for different users. Access restricted to certain worksheet

    Thanks,

    It errors on the final Next i just after Sheets(i).Visible = True

    Please Login or Register  to view this content.

  15. #15
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Multiple passwords for different users. Access restricted to certain worksheet

    Rather than moving that End If you needed to add another End If. Didn't spot that as I was replying from my phone.
    Try the below code:

    BSB

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Excell Multiple Users and passwords
    By morne.goosen in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-12-2014, 07:37 AM
  2. Allow users (with passwords) to view and edit multiple sheets per user.
    By tjwalsh626 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-17-2014, 08:38 PM
  3. Replies: 1
    Last Post: 09-05-2013, 10:12 AM
  4. access to worksheet protected by different passwords
    By galvinpaddy in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-22-2011, 08:01 PM
  5. Multiple passwords for different users
    By pooley343 in forum Excel General
    Replies: 2
    Last Post: 05-10-2011, 12:10 PM
  6. Restricted activity acces for certain users
    By anwitha in forum Excel General
    Replies: 1
    Last Post: 02-01-2011, 12:09 PM
  7. Limiting worksheet access through passwords
    By tvwhome in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 06-22-2010, 03:52 PM

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