+ Reply to Thread
Results 1 to 2 of 2

Hide a row based on value

Hybrid View

  1. #1
    Registered User
    Join Date
    04-18-2012
    Location
    Maryland, USA
    MS-Off Ver
    Excel 2007
    Posts
    19

    Hide a row based on value

    I am attempting to hide an entire row if the value in a specific cell is less than 3. I was attempting to use an If Then, but it doesn't seem to work... Any help would be appreciated. I've tried both pieces of code below but neither is working...

    For Each Row In [A6:I2000]
    If Cell("$I2") < 3 Then Rows("2:2").Hidden = True
    Next Row


    For Each Cell In [A6:I2000]
    If Cell("$I2") < 3 Then Rows("2:2").Hidden = True
    Next Cell

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

    Re: Hide a row based on value

    Your on the right track. Try:

    Sub LessThan3()
    Dim ws As Worksheet:    Set ws = Sheets("Sheet1") 'may need to change
    Dim rCell As Range
    
    Application.ScreenUpdating = False
    
    For Each rCell In ws.Range("A6:I2000")
        If Not IsEmpty(rCell) Then
        If rCell.Value < 3 Then
            rCell.EntireRow.Hidden = True
        End If
        End If
    Next rCell
    
    Application.ScreenUpdating = True
    
    End Sub

+ 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