+ Reply to Thread
Results 1 to 6 of 6

Hide Rows based on Cell Value

  1. #1
    Registered User
    Join Date
    03-09-2010
    Location
    Leuchars, Scotland
    MS-Off Ver
    Excel 2003
    Posts
    7

    Hide Rows based on Cell Value

    I'm having trouble with what I think should be some easy code.... and hoping somebody can help me.

    I'm trying to input a Private Sub Worksheet_Change(ByVal Target As Range) to automatically hide/unhide some rows based on a cell reference (in my case it's just a drop down in the cell with either Yes/No). So, if the user selects Yes, it will show some rows, and if no, it will hide them.

    I can get this to work just fine for one instance... but I want it to work in more than one instance. For example:

    User selects Yes in C5, Show rows 6:10.
    User selects No in C12, Hide rows 13:20
    User selects Yes in C60, Show rows 62:72


    No matter what I've tried, I can get C5 to work properly... but then nothing else works.

    Anyone able to point me in the right direction?

    Thank in advance!

  2. #2
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: Hide Rows based on Cell Value

    Hi
    Pls upload sample file
    Click *, if my suggestion helps you. Have a good day!!

  3. #3
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Hide Rows based on Cell Value

    It will be good if you attach a sample file along with the code which you are using. Ensure that the sample file containing dummy data is in the same format as the original file.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  4. #4
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Hide Rows based on Cell Value

    Hi nogoodnames,

    You can use below code:-

    Please Login or Register  to view this content.
    Sample file :- Hide rows based on value.xlsm

    Regards,
    DILIPandey

    <click on below 'star' if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), [email protected]

  5. #5
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Hide Rows based on Cell Value

    try n see if it helps you

    Later edit: too late! )))
    Attached Files Attached Files
    Last edited by john55; 04-21-2012 at 11:23 AM.
    Regards, John55
    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.

    ...enjoy -funny parrots-

  6. #6
    Registered User
    Join Date
    03-09-2010
    Location
    Leuchars, Scotland
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Hide Rows based on Cell Value

    Sorry I took so long to reply!

    I can't attach a sample as the file is at work... and... well... I'm not.

    My code looked very similar to Dilipandey's, but judging by his code, and from memory, it looks like I was putting my End If's in the wrong location.

    However, both John55 and Dilipandey's work perfect for me, so thanks a million!

+ 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