Results 1 to 4 of 4

Thread: Showing & Hiding Rows based on values

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Jan 2018
    Location
    Nova Scotia
    Posts
    83
    Location

    Showing & Hiding Rows based on values

    Hi,
    I created a toggle button to hide rows based on a value. I found some code for this and it works great. However, I can't make it show rows looping through the hidden rows. Basically, I want to do the opposite as the first part of the code.

    Here is the code:

    Private Sub ToggleButton2_Click()
      Dim rg As Range, c As Range
      Dim firstAddress As String
        Set rg = Range("B4", Cells(Cells.Rows.Count, "B").End(xlUp))
    'Application.ScreenUpdating = False
    
    If ToggleButton2.Value = True Then
    With rg
        Set c = .Find(what:="Complete", lookat:=xlWhole, LookIn:=xlValues)
        If Not c Is Nothing Then
            firstAddress = c.Address
            Do
                c.EntireRow.Hidden = True
                Set c = .FindNext(c)
                If c Is Nothing Then Exit Do
            Loop While c.Address <> firstAddress
        End If
    Application.ScreenUpdating = True
    End With
        Range("M1").Select
    Else
        Cells.Select
        Selection.EntireRow.Hidden = False
        Range("M1").Select
    End If
    End Sub
    Last edited by Paul_Hossler; 01-21-2019 at 08:14 AM. Reason: Use CODE Tags please

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •