+ Reply to Thread
Results 1 to 3 of 3

Hide/unhide tabs based on cell value in table VBA

  1. #1
    Registered User
    Join Date
    03-01-2012
    Location
    Nottingham, England
    MS-Off Ver
    Excel 2010
    Posts
    64

    Hide/unhide tabs based on cell value in table VBA

    Hello

    I'm building an Excel model that requires several different access rights levels for different user groups. The model prompts the user to select which level they require and then enter the correct password. Currently I have manually set up the 'Visible' and 'Protect Sheet' properties in the VBA code for each sheet based on the access level required, but this is time consuming and requires regular maintenance as and when requirements change.

    The first tab in the model is an 'Index' tab that contains a table of the tab names in the first column, and then for each access level ('Admin', 'Editor' and 'Viewer') there are two columns - one governs the Visibility of each tab (ie: Visible, Hidden or Very Hidden) and the other column the protect sheet status (a simple 'Yes' or 'No').

    What I'm looking for is code that I can add to the User Forms code (for the password pop-ups), so that when the user enters the correct password, for each sheet the code reads along the table in the 'Index' tab and sets the 'Visible' and 'Protect Sheet' properties based on the values in the table. The table in questions looks like the attached example below:

    IndexTab_AccessRightsTable.jpg

    As you can see from the settings used in this example, only 'Admin' level users have full unlocked access to every tab, the principle being that it gives model architects final control of the overall structure and behaviour of key aspects of the model.

    If anyone can help it would be hugely appreciated as always

    Kind regards and many thanks
    Stephen

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Hide/unhide tabs based on cell value in table VBA

    It would be easier to help if we could see what your workbook looks like, including the userform and any macros currently in use. Perhaps you could attach a copy of your file, de-sensitized if necessary.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: Hide/unhide tabs based on cell value in table VBA

    In addition, are you doing this to prevent people from making mistakes or are you dealing with sensitive data?

    I ask because Excel isnt meant to protect sensitive data. If you are doing it as a preventative measure to keep people from goofing things up, ignore the rest of my post.

    Sheet protection is a preventative measure to keep people from making mistakes and overwriting formulas etc, its NOT a security feature. It also has no effect on the visibility of a sheet as far as I am aware (so a user could simply unhide a sheet if they want manually). Sheet protection is very easy to circumvent alone. VBA to be honest removes any left over sense of "security" it may have given because you are storing the passwords in the file itself and passing them in plain text. There are numerous ways someone could extract the information and/or credentials or just plain circumvent them completely.

    The only "secure" protection Excel offers out of the box is password to open and password to modify. These actually encrypt the file, however they are all or nothing solutions. As soon as someone has a password to open or modify all bets are off and we are back to the root issue, which is Excel isnt meant to securely store data. Worksheet, workbook and even VBA protection are essentially useless as anything more then preventing people who dont care to poke at it from making mistakes.
    Ways to get help: Post clear questions, explain your overall goal, supply as much background as possible, respond to questions asked of you by those trying to help and post sample(s) files.

    "I am here to help, not do it for people" -Me

+ 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. hide/unhide all tabs
    By cmorten82 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-11-2015, 07:03 PM
  2. How to Hide-Unhide Row Based on a Cell Value
    By putritersenyum in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-18-2015, 06:56 AM
  3. [SOLVED] vba code for hide/unhide tabs based on color
    By Allseasons in forum Excel Programming / VBA / Macros
    Replies: 25
    Last Post: 03-17-2014, 04:04 PM
  4. [SOLVED] Unhide and Hide row(s) based on value in a cell in the row above
    By jammi1710 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-18-2014, 01:27 AM
  5. Show / hide tabs based on a table
    By Yorick in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-11-2014, 04:54 PM
  6. Using checkboxes on summary sheet to name tabs and hide/unhide tabs
    By eew2201 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-11-2012, 06:13 PM
  7. Hide/Unhide Tabs VBA
    By JIBG in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-20-2007, 03:08 AM

Tags for this Thread

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