+ Reply to Thread
Results 1 to 14 of 14

Macro to hide rows based on selected Month

  1. #1
    Forum Contributor
    Join Date
    11-03-2014
    Location
    Belgrade
    MS-Off Ver
    2010
    Posts
    348

    Exclamation Macro to hide rows based on selected Month

    Hi All,

    I need a macro that will hide a rows based on selected Case in cell "A1".
    To be more precise what do I mean. Case in cell A1 means: 1 (is January), 2 (February) and so on.
    When I put the data e.g. January (range D3:H3) and (D22:F22) and when I select case 1 in cell A1, I want from Macro to hide ALL rows where I don't have the Data for other Months, but Quater range need to be skipped as I don't want to hide it.

    And I will have similar tables also in Sheet2, Sheet3 etc.

    So, is it possible to write a code for this?

    Thank you in advance.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Macro to hide rows based on selected Month

    Copy code into each sheet module

    Please Login or Register  to view this content.
    If you are happy with my response please click the * in the lower left of my post.

  3. #3
    Forum Contributor
    Join Date
    11-03-2014
    Location
    Belgrade
    MS-Off Ver
    2010
    Posts
    348

    Re: Macro to hide rows based on selected Month

    I put the Code, select the number in cell A1 but nothing happens?
    Did I do something wrong?

    Thank you.
    Attached Files Attached Files

  4. #4
    Forum Contributor tax112's Avatar
    Join Date
    02-28-2013
    Location
    Thailand
    MS-Off Ver
    Excel 2016 | 2019
    Posts
    438

    Re: Macro to hide rows based on selected Month

    Quote Originally Posted by toci View Post
    I put the Code, select the number in cell A1 but nothing happens?
    Did I do something wrong?

    Thank you.
    You copy the Code does not place.
    "Copy code into each sheet module"

  5. #5
    Forum Contributor
    Join Date
    11-03-2014
    Location
    Belgrade
    MS-Off Ver
    2010
    Posts
    348

    Re: Macro to hide rows based on selected Month

    Still nothing. I copied the Code to each Sheet as you can see in this attachment.
    Attached Files Attached Files

  6. #6
    Forum Contributor tax112's Avatar
    Join Date
    02-28-2013
    Location
    Thailand
    MS-Off Ver
    Excel 2016 | 2019
    Posts
    438

    Re: Macro to hide rows based on selected Month

    Quote Originally Posted by toci View Post
    Still nothing. I copied the Code to each Sheet as you can see in this attachment.
    It is still operating normally.
    Try Enable macro

  7. #7
    Forum Contributor
    Join Date
    11-03-2014
    Location
    Belgrade
    MS-Off Ver
    2010
    Posts
    348

    Re: Macro to hide rows based on selected Month

    Yes, I enabled macros but I need to edit it, because when I select "Case 2" (February) I need to see the Data for January and February together. That means e.g. when I select Case 6, I want to see all the data from January till Jun and to hide the rest of.
    Also, when I select "Blank" in A1 I get error. Or it would be better when select "Blank" in A1 to unhide all Data.

    Thank you very much on cooperation.

  8. #8
    Forum Contributor tax112's Avatar
    Join Date
    02-28-2013
    Location
    Thailand
    MS-Off Ver
    Excel 2016 | 2019
    Posts
    438

    Re: Macro to hide rows based on selected Month

    Quote Originally Posted by toci View Post
    Yes, I enabled macros but I need to edit it, because when I select "Case 2" (February) I need to see the Data for January and February together. That means e.g. when I select Case 6, I want to see all the data from January till Jun and to hide the rest of.
    Also, when I select "Blank" in A1 I get error. Or it would be better when select "Blank" in A1 to unhide all Data.

    Thank you very much on cooperation.
    You add commands:
    HTML Code: 

  9. #9
    Forum Contributor tax112's Avatar
    Join Date
    02-28-2013
    Location
    Thailand
    MS-Off Ver
    Excel 2016 | 2019
    Posts
    438

    Re: Macro to hide rows based on selected Month

    Try:
    HTML Code: 

  10. #10
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Macro to hide rows based on selected Month

    Yes, I enabled macros but I need to edit it, because when I select "Case 2" (February) I need to see the Data for January and February together. That means e.g. when I select Case 6, I want to see all the data from January till Jun and to hide the rest of.
    This is completely different from what you initially asked for.

    I tested the code I supplied on the worksheet you supplied and it worked perfectly fine based upon your initial parameters.
    Last edited by stnkynts; 03-10-2016 at 01:30 PM.

  11. #11
    Forum Contributor
    Join Date
    11-03-2014
    Location
    Belgrade
    MS-Off Ver
    2010
    Posts
    348

    Re: Macro to hide rows based on selected Month

    Sorry for misunderstood! I will checking this code few days more and back here with info.
    Thank you so much!

  12. #12
    Forum Contributor
    Join Date
    11-03-2014
    Location
    Belgrade
    MS-Off Ver
    2010
    Posts
    348

    Re: Macro to hide rows based on selected Month

    Is it possible to edit this code so when I select "Case 2" in cell A1 I would like to see the Data for January and February together and so on.

    Also, if I select "Blank" in A1 is it possible to see all Months?

    Thanks!

  13. #13
    Forum Contributor
    Join Date
    11-03-2014
    Location
    Belgrade
    MS-Off Ver
    2010
    Posts
    348

    Re: Macro to hide rows based on selected Month

    I've noticed that if I put the table in different range in Sheet2 (changed few things in Macro for Sheet2), back to Sheet1 and when select Case in A1, in Sheet2 nothing happens.

    How to fix this?
    Attached Files Attached Files

  14. #14
    Forum Contributor
    Join Date
    11-03-2014
    Location
    Belgrade
    MS-Off Ver
    2010
    Posts
    348

    Re: Macro to hide rows based on selected Month

    Anybody to jump

+ 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. [SOLVED] Automatically hide and unhide rows based on selected month
    By dondonordas in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-24-2018, 02:07 AM
  2. [SOLVED] open worksheet based on month to specific sheet named after month and hide rest
    By ianmcw in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-23-2014, 10:19 PM
  3. Need help creating macro to hide rows based upon whether 1 of 3 rows have data
    By BigEdJr in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 01-17-2014, 02:58 PM
  4. Replies: 2
    Last Post: 01-30-2013, 03:16 AM
  5. Excel Macro based on Month selected
    By mille1sj in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-01-2012, 12:21 PM
  6. hide the rows that are not selected VBA macro
    By herukuncahyono in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-08-2011, 12:18 AM
  7. Macro to Hide rows based on 'Sum'
    By rakeshplb in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-26-2009, 11:28 AM

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