+ Reply to Thread
Results 1 to 5 of 5

Classic hide rows if cell value is zero - not working, please help!

Hybrid View

  1. #1
    Registered User
    Join Date
    11-12-2012
    Location
    Mars
    MS-Off Ver
    Excel 2007
    Posts
    2

    Classic hide rows if cell value is zero - not working, please help!

    I have drop downs on another sheet that control cells so that if the drop down is the same as the value next to the cell it shows a 1 if not a zero.

    I want to hide the rows that contain cells with a zero and have read forum answers but for some reason this isn't working. It comes up with Error 1001 object defined or application defined error and highlights

    "Rows(rCell).EntireRow.Hidden = True".

    Or says my argument isn't optional.

    I would also like to expand this and hide irrelevant columns as well once this is cracked.


    Private Sub Worksheet_Change(ByVal Target As Range)
             
     Dim rCell, rRange As Range
    
        For Each rCell In Range("B10:B921")
            
            If rCell.Value = 0 Then
       
                Rows(rCell).EntireRow.Hidden = True
                
             End If
         
             If rCell.Value = 1 Then
             
                Rows(rCell).EntireRow.Hidden = False
              
             End If
            
            Next
    
    End Sub
    Any help is appreciated.

    Thanks

    D

    Moderator's Edit: Use code tags when posting code. To do so, select your code and click on the # icon above.
    Last edited by arlu1201; 11-12-2012 at 08:04 AM.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Classic hide rows if cell value is zero - not working, please help!

    Remove rows from.Just
    rCell.EntireRow.Hidden = True
    Rows(rCell).EntireRow.Hidden = True
    
    Rows(rCell).EntireRow.Hidden = False

  3. #3
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Classic hide rows if cell value is zero - not working, please help!

    I'm afraid your post does not comply with Rule 8 of our Forum RULES. Cross-posting is when you post the same question in other forums on the web. You'll find people are disinclined to respond to cross-posts because they may be wasting their time solving a problem that has been solved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser)to the cross-post. Expect cross-posts without a link to be closed a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  4. #4
    Registered User
    Join Date
    11-12-2012
    Location
    Mars
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Classic hide rows if cell value is zero - not working, please help!

    JP - I understand you reasoning. However the number of threads that I've seen over that last few days would be loads hence title "classic". Plus the 5 mins of attention from AB33 to give my code a tweak means it now works!!

    So thank you AB33 as this had been doing my nut in!

  5. #5
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Classic hide rows if cell value is zero - not working, please help!

    I guess you didn't read the rule or the link

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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