+ Reply to Thread
Results 1 to 13 of 13

Hide all worksheet except 5 input sheets and a 6th sheet selected in a drop down list

  1. #1
    Registered User
    Join Date
    01-13-2014
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    7

    Hide all worksheet except 5 input sheets and a 6th sheet selected in a drop down list

    I have been trying to solve this problem from previous threads and can not seem to get it right

    I have and excel book with 53 sheets.

    I am looking to keep 5 input tabs permanently unhidden:
    “Input 1”, “Input 2”, “Input 3”, “Input 4” and “Input 5”

    I also want to unhide one of the other forty-eight hidden tabs depending on the selection made from the drop down list in “'Input 1'!C52”

    The Names in the drop down list are the same as those on the forty-eight hidden sheets

    I am at my wits end and would really appreciate any help,

    thanks in advance

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Hide all worksheet except 5 input sheets and a 6th sheet selected in a drop down list

    Hi,

    Try

    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Contributor
    Join Date
    01-21-2013
    Location
    Aberdeen, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    258

    Re: Hide all worksheet except 5 input sheets and a 6th sheet selected in a drop down list

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    01-13-2014
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Hide all worksheet except 5 input sheets and a 6th sheet selected in a drop down list

    Gents,

    Thank you so much for you quick responses you have just made my day that much easier.

    Richard, I couldn't get your code to work but RichTea 88 yours worked perfectly first time,

    Thank you again,

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Hide all worksheet except 5 input sheets and a 6th sheet selected in a drop down list

    Quote Originally Posted by brianfarrell06 View Post
    Gents,

    Thank you so much for you quick responses you have just made my day that much easier.

    Richard, I couldn't get your code to work

    Thank you again,
    Strange given that the two answers are essentially the same. The only difference is that my code hides all worksheets apart from the C52 named sheet whereas RichTea's hides all sheets which have the characters "Input" in the tab name. Does that imply that you have other sheets (other than the sheet identified in C52) that you don't want to hide?

  6. #6
    Forum Contributor
    Join Date
    01-21-2013
    Location
    Aberdeen, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    258

    Re: Hide all worksheet except 5 input sheets and a 6th sheet selected in a drop down list

    Hey Richard,

    I just gave your code a try and it works fine the first time I try it, but when I change the input in C52 and try it a second time I get an error and it hides all the sheets except Input 5...

    I can't work out why. The error occurs on this line
    Please Login or Register  to view this content.
    and when I hover it says
    ws.Visible = xlSheetHidden = False

  7. #7
    Forum Contributor
    Join Date
    01-21-2013
    Location
    Aberdeen, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    258

    Re: Hide all worksheet except 5 input sheets and a 6th sheet selected in a drop down list

    In fact the error only occurs if I've selected an unnamed sheet, for example 'Sheet8'.

  8. #8
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Hide all worksheet except 5 input sheets and a 6th sheet selected in a drop down list

    Hi,

    Well obviously if the text you have in C52 isn't a named sheet then the macro will fall over as you've found. You'd need to trap that error probably with an OnError Goto labelname:

    where labelname: is at the last line of the code. Or better still with a line afterwards which says
    Please Login or Register  to view this content.
    and a preceding line
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    01-21-2013
    Location
    Aberdeen, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    258

    Re: Hide all worksheet except 5 input sheets and a 6th sheet selected in a drop down list

    Sorry, what I was meaning was that the sheet does exist, but its just the default name, "Sheet8". Though the error does occur if there is no sheet.

    But an Error Handler would probably work for that as well. I was just curious as to what it could be because I can't see why your code wouldn't work.

  10. #10
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Hide all worksheet except 5 input sheets and a 6th sheet selected in a drop down list

    Hi,

    Are you sure that C52 doesn't say "Sheet 8" but the tab name is "Sheet8" - or vice versa?

  11. #11
    Forum Contributor
    Join Date
    01-21-2013
    Location
    Aberdeen, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    258

    Re: Hide all worksheet except 5 input sheets and a 6th sheet selected in a drop down list

    Haha,

    Right I just tried it again and the error doesn't occur if 'Sheet8' is visible in the first place.

    But if you'd already searched for another sheet 'Check' for example, then Sheet8 is hidden. Now when you try to search for sheet 8, that's when the error occurs. (I've attached the workbook I was testing with)

    :P Don't think I've seen a solved thread go on this long
    Attached Files Attached Files

  12. #12
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Hide all worksheet except 5 input sheets and a 6th sheet selected in a drop down list

    I think this only happens when the sheet in question is in the last position.i.e. the most right hand sheet. In this particular circumstance all the other sheets have been hidden when this line of code becomes live and since Excel must have at least one sheet visible it complains. The easiest solution is to use another instance of the For..Next loop first in the code so that all sheets are unhidden.

    i.e.

    Please Login or Register  to view this content.
    Yes I know you already have a solution but it's nice to find the anomalies

  13. #13
    Forum Contributor
    Join Date
    01-21-2013
    Location
    Aberdeen, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    258

    Re: Hide all worksheet except 5 input sheets and a 6th sheet selected in a drop down list

    I'm exactly the same, couldn't have let it lie!

    Let it never be said that too many ***** spoil the broth (also a Richard)

+ 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. Drop down list that changes selected sheet
    By Mike_StGeorge in forum Excel - New Users/Basics
    Replies: 7
    Last Post: 06-22-2017, 01:39 PM
  2. Replies: 8
    Last Post: 02-12-2013, 05:08 AM
  3. Replies: 2
    Last Post: 12-06-2012, 05:52 PM
  4. Hide/Unhide rows on multiple sheets when dropdown selected from sheet 1
    By tammhelp in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-02-2012, 10:33 PM
  5. Value selected on drop down list, look-up on different sheet
    By liseladele in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-21-2006, 10:30 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