Unhide multiple sheets based on username

  • Trying to make sure I post corectly from Title to end....


    Working in Excel 2007 and I've done a lot of reasearch on this before posting to hopefully avoid getting flamed for either a repeat post or stupid question - not sure I'm succesful on either count...


    What I intend:

    • Workbook has multiple Sheets
    • All Sheets are veryhidden on Open
    • On Open check for username to determine which Sheets are unhidden (some users should have only one Sheet visible, other users will have multiple, a few will have all visible)
    • Open Sheets
    • Allow edits by username
    • On Save/Close veryhide all Sheets


    Here's the code I have in ThisWorkbook:



    I've found multiple posts both here and in other forums about arrays and other methods to specify multiple Sheets to unhide but insertion of all return an error of some sort. No doubt because despite a lot of trial and error I really have no idea how to include the additional code in what I've aready done.


    Thanks in advance for any help!

  • Re: Unhide multiple sheets based on username


    First of all, since you have a correspondence between UserIDs and Sheet names, let me suggest that you have a VeryHidden sheet that allows you to put that correspondence into some kind of table. For instance, each column has a UserID as the first line and under that is a list of all the Sheets that should be unhidden for that UserID.


    With that Sheet code can be written to manage sheets very easily.


    I will try to set up a sample workbook that will show these ideas.

  • Re: Unhide multiple sheets based on username


    I've found a few bits of code which utilize a user entered ID and Pass and a table reference like vwankerl suggests but as noted I am a VBA novice (that's a generous use of the word) and cannot adapt to Username.


    Thanks in advance.

  • Re: Unhide multiple sheets based on username


    GMAGDNAA,


    A question to clarify, is the userid the same as the userid used to login to the workstation or if you are on a network, to login to the Active Directory? That is what I assumed from the code you posted in your original post.


    vwankerl

  • Re: Unhide multiple sheets based on username


    Try this example you should be able to adapt it to your use

  • Re: Unhide multiple sheets based on username


    royUk -


    That was one of the examples I found but I do lack the knowledge to adapt it to my needs, i.e. pulling the Username based on user opening the spreadsheet, then cross referencing to the access table.


    I'll continue to work on it but will appreciate additional help/direction.

  • Re: Unhide multiple sheets based on username


    Quote from vwankerl;614152

    GMAGDNAA,


    A question to clarify, is the userid the same as the userid used to login to the workstation or if you are on a network, to login to the Active Directory? That is what I assumed from the code you posted in your original post.


    vwankerl


    Correct, I am looking to pull the Active Directory ID.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!