+ Reply to Thread
Results 1 to 11 of 11

make certain worksheets show/hide when others are clicked

  1. #1
    Registered User
    Join Date
    01-06-2010
    Location
    Olympia, Washington
    MS-Off Ver
    Excel 2007
    Posts
    6

    make certain worksheets show/hide when others are clicked

    Essentially what I want can be shown in outline form:

    I. Stats (workbook)
    A. 2009 (worksheet)
    1. Jan (worksheet that appears only when 2009 worksheet is clicked)
    2. Feb (worksheet that appears only when 2009 worksheet is clicked)
    B. 2010 (worksheet)
    1. Jan (worksheet that appears only when 2010 worksheet is clicked)
    2. Feb (worksheet that appears only when 2010 worksheet is clicked)

    I was hoping there was a way to have one workbook that displays only the years (2009, 2010) as worksheet tabs but once clicked, would reveal 12 nested worksheets (one for each month). Once a different year worksheet was clicked, the month worksheets currently displayed would hide again.

    Thanks

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    re: make certain worksheets show/hide when others are clicked

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    Edited this time
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: make certain worksheets show/hide when others are clicked

    Depending on your data layout it might be more efficient to store all data in one sheet then use a PivotTable to group by Months & Years

  4. #4
    Registered User
    Join Date
    01-06-2010
    Location
    Olympia, Washington
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: make certain worksheets show/hide when others are clicked

    I'll look into the Pivot Table option. Thanks!

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: make certain worksheets show/hide when others are clicked

    This might helpyou get started

    http://excel-it.com/pivot_tables.htm

    Post back if you need further help, some dummy data in a workbook would be useful

  6. #6
    Registered User
    Join Date
    12-28-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    98

    Re: make certain worksheets show/hide when others are clicked

    do you want the data on the sheet to be displayed on a button click or the entire sheet to be made unhidden on a button click? I have had similar questions and was helped along the way with those solutions.

    create a button and then in the VB code insert this to make the tab unhide.

    Please Login or Register  to view this content.
    if you want to hide the other sheets once you are in this one, then add the following code after the "Application.Goto" function

    Please Login or Register  to view this content.
    you can add as many of those as you want, all you have to so is change the name of the month and yr.

    hope that helps and was what you were asking for.

    James

  7. #7
    Registered User
    Join Date
    12-28-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    98

    Re: make certain worksheets show/hide when others are clicked

    Please Login or Register  to view this content.
    i was thinking about your question a little more and believe this is a better example of what you are looking to do....just creat a sheet in your workbook that would be like a navigation page (dashboard) on that page create a button labled [2009]. add the code above and then save. close and restart the work book and enable macros, click the button and watch it work.

    plus the code has explanations in it for you to use. Any how hope this helps.

    James
    Last edited by jabryantiii; 01-06-2010 at 05:15 PM.

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: make certain worksheets show/hide when others are clicked

    You don't need to close & save a work book when adding code. It will run anyway. Just close & save when finished

  9. #9
    Registered User
    Join Date
    01-06-2010
    Location
    Olympia, Washington
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: make certain worksheets show/hide when others are clicked

    Thanks for the code and suggestions jabryantiii. In trying to implement some of your ideas I'm running into a proplem with the (Name) and Name properties of each worksheet within Excel. I'm used to coding with VB.Net in Visual Studio and selecting a Name property (how the control is referred to in code) and a Text property (what it displays to the user). In Excel it seems that Name property is what displays while the (Name) property is how the worksheet is uniquely identified. However, I'm unable to use the same Name (i.e. "January") for more than one worksheet even when they have different (Name) property values (i.e. wksht1, wksht13). Does anyone have any experience dealing with this issue of wanting to use the same display name for more than one worksheet?

  10. #10
    Registered User
    Join Date
    12-28-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    98

    Re: make certain worksheets show/hide when others are clicked

    with the issue of names, in this case January 09 vs January 10, simply adding an underscore will make all the difference.

    January_09 (make sure that both the code and the tab name reflect this)

    January_10 (make sure that both the code and the tab name reflect this)


    RoyUK..
    the reason i stated to save close and restart, is due to the fact that some version of Excel as well as security settings will not allow you to run a macro unless you do this. Not knowing what version of Excel or what his security settings are, leads me to the safest way to test and ensure that the macro will run properly.
    Last edited by jabryantiii; 01-08-2010 at 01:28 PM.

  11. #11
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: make certain worksheets show/hide when others are clicked

    You don't need to close a workbook after adding code. Macros will work when added to a workbook that is open.

    With 2007 you must save as a macro enabled workbook when finished

+ 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