+ Reply to Thread
Results 1 to 3 of 3

Macro to hide rows based on a range of data in a cell

Hybrid View

  1. #1
    Registered User
    Join Date
    06-17-2013
    Location
    Wilkes-Barre, PA
    MS-Off Ver
    Excel 2010
    Posts
    16

    Macro to hide rows based on a range of data in a cell

    Hi. I am looking to hide rows based on the data in cell Q. I want to hide all data greater than 99 but less than 106. Thanks for your help.

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Macro to hide rows based on a range of data in a cell

    Something like
    Sub HideRowsIF()
        
        Dim ws1 As Worksheet
        Dim cRng As Range, oC As Range
        
        Set ws1 = Worksheets("Sheet1")
        Set cRng = ws1.Range(ws1.Cells(2, 17), ws1.Cells(ws1.Rows.Count, 17).End(xlUp))
        For Each oC In cRng
            If oC.Value > 99 And oC.Value < 106 Then
                oC.EntireRow.Hidden = True
            End If
        Next oC
        
    End Sub
    should do the job!
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro to hide rows based on a range of data in a cell

    FWIW.

    Sub eorydc()
    Range("Q2:Q" & ActiveSheet.UsedRange.Rows.Count).AutoFilter 1, "<99", xlOr, ">106"
    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