Sully1440
01-21-2019, 07:48 AM
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
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