Closed Thread
Results 1 to 12 of 12

hide / unhide separate sheets based on password

  1. #1
    Registered User
    Join Date
    03-18-2010
    Location
    West Coast
    MS-Off Ver
    Excel 2007
    Posts
    1

    Exclamation hide / unhide separate sheets based on password

    Greetings,

    I am using Excel 2007. I have a workbook with over 50 sheets in it. I want to see if I could make all of the worksheets hidden from view unless there is a password that will be entered, in order to view the corresponsing sheets. I also need to be able to have the sheets hidden again once the file is saved ( or on close ). Not everyone will have access to the same sheets. Only one person ( aside from myself ) will have access to all of the sheets.

    Is there a way to assign individual passwords for each separate user so that I can have the user enter their password to reveal the sheet(s) that they will be working on?

    Thanks!

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    re: hide / unhide separate sheets based on password

    1) You can't hide ALL the sheets, obviously, so let's keep Sheet1 visible. Put this in the ThisWorkbook module to accomplish that.
    Please Login or Register  to view this content.


    2) This macro can be used to prompt a user for a password to ID which sheets should be made visible
    Please Login or Register  to view this content.
    That can be attached to a button, or even reconfigured into a Workbook_Open prompt.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile re: hide / unhide separate sheets based on password

    Good afternoon spudinsane

    I have a template available that does exactly what you require. It stores a list of users and passwords, and which sheets are to be accessed by which users. You, as administrator, can see all worksheets and control which sheets users can access. This was originally developed for XL2003, but should work fine on 2007.

    The security on this isn't 100%, as we are using Excel, which by its very nature is not completely secure, but it should keep out most nosey parkers.

    If you prefer to write something of your own, then all my code is unprotected, so you could use that to get some ideas, or fine tune the workings.

    If you would like a copy of this template, then please PM me your e-mail address.

    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  4. #4
    Registered User
    Join Date
    10-20-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    58

    re: hide / unhide separate sheets based on password

    @jbeaucaire

    I have contact 'dominicb' and am waiting for his template but in the meantime can you help?

    I have added the code to ThisWorkbook and added the password to ID code in Sheet1 module (Changing the password to 'test')

    On Sheet1 I have created a button and assigned the macro.

    All the sheets are hidden expect Sheet1, as expected, but when I click and enter password 'test' the sheets stay hidden.

    How does the ID work?

    I have attached what I have entered. Can you look where I am going wrong? Thanks
    Attached Files Attached Files

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    re: hide / unhide separate sheets based on password

    A couple of tweaks. First, I was saving that wb too many times, here is the corrected code for ThisWorkbook module:
    Please Login or Register  to view this content.

    Then, the PwdCheck macro goes into a code module, not the sheet module. (Insert > Module). A small tweak for that as well:
    Please Login or Register  to view this content.

    When I type in "john" it unhides sheet2 as expected and when I close the workbook it hides all and saves as expected.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    10-20-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    58

    re: hide / unhide separate sheets based on password

    Understand what you have done. Thank you.

    If I choose 'admin', Sheet2 and 3 show. Is it possible to then click the button and type 'john' and only see Sheet2?

    This is more curiosity than anything...

    Also, is it possible to stop people from accessing the code?

    Many thanks.

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    re: hide / unhide separate sheets based on password

    I've posted this several times


    PASSWORD FORM4.zip
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  8. #8
    Registered User
    Join Date
    10-20-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    58

    re: hide / unhide separate sheets based on password

    royuk,

    Do apologies but I tried one of your links regarding this solution earlier this afternoon. Your link sent me to a third party source and it had expired or was no longer avaliable.

    If I find that particular post later tonight, I will update you of its location.

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    re: hide / unhide separate sheets based on password

    you could add back in the same "hideall" logic used in the other macro so each time the macro is run, all sheets hide again.
    Please Login or Register  to view this content.

    You can password protect your VBA by right-clicking the VBAProject and going into Properties.

  10. #10
    Registered User
    Join Date
    03-26-2011
    Location
    Oslo
    MS-Off Ver
    Excel 2007
    Posts
    4

    re: hide / unhide separate sheets based on password

    Hi All,

    I looked at Roy's attached workbook and it suits quite well to my purposes...

    There is just 1 thing I would like to change:
    A specific user gets only his/her dedicated sheet visible. My users would need access to several sheets ..depending on their "lvl". Not just 1 sheet. Could this be done?

    Also ... is there a way to prevent changing the sheetname? This would royally mess up the functionality.

    Hope you can help
    Sige

  11. #11
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    re: hide / unhide separate sheets based on password

    Hi sigeg... Welcome to the forum.

    Be sure to read through the Forum Rules so you can use and follow them effectively. For instance, you'll need to start your own thread and ask your questions there, include your own sample sheets, and if you find this thread possibly relevant, include a link to this thread.

    Forum rules forbid hijacking one thread with new questions of your own, this is meant to benefit you, to insure the most possible new eyes look at your new question(s).

  12. #12
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    re: hide / unhide separate sheets based on password

    As Jerry points out, your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread.

Closed 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