+ Reply to Thread
Results 1 to 8 of 8

Hide and Unhide sheet

  1. #1
    Registered User
    Join Date
    02-22-2012
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    4

    Hide and Unhide sheet

    Need some help please (I'm not a programmer)

    I have a drop list on a worksheet. I need to hide certain worksheet (say worksheet B and C) when the second item in the drop list is selected (let say that second item is = 2).
    Lets say the number of worksheets are A -- F
    Otherwise all sheets must be visible.

    The macro on my worksheet is

    Please Login or Register  to view this content.
    The sub-routine being called are: ....

    Please Login or Register  to view this content.
    I am getting errors that I can't figure out -
    Last edited by svirgo; 02-23-2012 at 08:16 PM.

  2. #2
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: Hide and Unhide sheet

    When you post code please enclose your macro code in code tags - please see our forum rules http://www.excelforum.com/forum-rule...rum-rules.html - Rule 3 will show you how to do this.
    The problem with the posted code is that there is no macro called SHORTMacro (unless you did not post that part of the code) - your macro will error out with "Sub or Function Not Defined" - is that the error you are getting?
    Just to shorten your code there is very little need to ever Select or Activate sheets - just use referencing e.g.
    Please Login or Register  to view this content.
    As the code is probably in Sheet A then there is no need to select sheet A as doing it this way Sheet A will remain the active sheet.
    Make sure with your code at least ONE sheet is visible.
    If that is not the error then please post a sample workbook with your code - make sure there is no sensitive/private data in the posted dummy workbook
    Hope this helps.
    Anthony
    Pack my box with five dozen liquor jugs
    PS: Remember to mark your questions as Solved once you are satisfied. Please rate the answer(s) by selecting the Star in the lower left next to the Triangle. It is appreciated?

  3. #3
    Registered User
    Join Date
    02-22-2012
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Hide and Unhide sheet

    Thanks mate,

    I have taken your advice and shorten my code.
    I left out the macro called SHORTMacro for brevity.
    Please see uploaded file
    Your help much appreciated.
    Attached Files Attached Files

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Hide and Unhide sheet

    Hi svirgo

    Welcome to the Forum!

    As smuzoen has suggested, you MUST wrap your code in code tags. This is not optional.
    Please Edit your post #1 to include code tags.
    To edit your post, press Edit Post, press Go Advanced to see the [#] button). Highlight your code then press the [#] button. Press Save Changes. The result will appear like this in the post window:

    Please Login or Register  to view this content.
    You probably should not anticipate response until you've done so.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  5. #5
    Registered User
    Join Date
    02-22-2012
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Hide and Unhide sheet

    I apologize - thanks for the info jaslake

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Hide and Unhide sheet

    Hi svirgo

    No apology necessary. Thanks.

  7. #7
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: Hide and Unhide sheet

    You just need to reference the named range in the worksheet change event. Change your code to
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    02-22-2012
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Hide and Unhide sheet

    Thanks mate - worked out well.

+ 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