+ Reply to Thread
Results 1 to 9 of 9

Hide or unhide worksheets from cell values in sheet 1

  1. #1
    Registered User
    Join Date
    02-12-2009
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2007
    Posts
    32

    Hide or unhide worksheets from cell values in sheet 1

    I want to set up a few workbooks with 11 sheets. Sheet 1 will in effect be an index, with True or False values in say cells D5:D14. The True/False values will be generated by form control check boxes in some of the workbooks and by IF(TODAY()>xxxx formulas or similar in other workbooks.

    I then want to be able to hide or unhide sheets 2-11 based on the True/False values in cells D5:D14 in sheet 1.

    Any guidance or assistance will be appreciated.
    Last edited by glenin; 02-19-2009 at 05:51 AM.

  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 or unhide worksheets from cell values in sheet 1

    Not sure where your macros are going to reside, but you can assign a macro to the checkbox.

    Here's a basic macro, paste it into a standard module:
    Please Login or Register  to view this content.
    Right-click on your check-box and ASSIGN MACRO, select this macro. Then edit the macro and add this to title:
    Please Login or Register  to view this content.
    Adding the "PRIVATE" simply hides the code when others are selecting macros to run manually.
    Last edited by JBeaucaire; 02-18-2009 at 08:34 PM.
    _________________
    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 JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Hide or unhide worksheets from cell values in sheet 1

    If you use THIS version, then the users won't be able to UNHIDE the sheets manually using the Format > Sheets > Unhide.
    Please Login or Register  to view this content.
    This version can only be unhidden again with a macro, this checkbox, for instance.

  4. #4
    Registered User
    Join Date
    02-12-2009
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Hide or unhide worksheets from cell values in sheet 1

    Thanks - one down one to go!

    I've just set up a test WB using your xlVeryHidden option and the hide/unhide works fine from the checkbox controls in sheet 1.

    Any suggestions on how to achieve the same hide/unhide effect without using a checkbox, but using a true or false formula result in cells in sheet 1?

    Example: Cell B5 in sheet 1 contains an IF formula testing whether TODAY() is greater than or equal to say June 30 2009. If the result is FALSE then sheet 2 is to be hidden, if TRUE then sheet 2 is to be unhidden.

    Thanks again for your assistance.

  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 or unhide worksheets from cell values in sheet 1

    This should do it:
    Please Login or Register  to view this content.
    By the way, this goes in the Worksheet module, not a standard module.

  6. #6
    Registered User
    Join Date
    02-12-2009
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Hide or unhide worksheets from cell values in sheet 1

    I'm struggling to get this one to go.

    After setting up a fresh test xlsm workbook I pasted the code to the sheet 1 module. I originally set up a formula in B5 to return a true or false value based on input at B3. No luck - no hide/unhide sheet 2.

    Then tried typing true or false directly into B5 - still no sheet 2 hide/unhide.

    Then tried pasting the code to the workbook module and carried out the same two tests as above - still no go. Also tried saving/reopening file but no change.

    I'm pretty new to VBA so I've probably missed something simple - any idea what I haven't done or haven't done right?

  7. #7
    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 or unhide worksheets from cell values in sheet 1

    Not sure. Here's a book with it working...
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    02-12-2009
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Hide or unhide worksheets from cell values in sheet 1

    Thanks for the sample WB - it works fine.

    I've check my WB again and again and can't find the difference - I'll have a fresh look tomorrow and let you know when/if I find my error.

    Your asistance much appreciated.

  9. #9
    Registered User
    Join Date
    09-07-2011
    Location
    Jasper, GA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Hide or unhide worksheets from cell values in sheet 1

    Hi all,

    First off, what I know about VBA would pass through the eye of a needle and not hit the sides.

    I have tried to use this code to hide a worksheet and it is not working. I added the code as shown but changed the test value and cell. I also changed the worksheet name to match my names. The code is in a worksheet named SAP_SCOPE and if F50 is FALSE the worksheet Financial_Accounting should not be displayed.

    Obviously the code is not being executed but I have no idea why.

    Thanks
    Last edited by Dropman; 09-08-2011 at 09:54 AM.

+ 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