YasserKhalil
Well-Known Member
Hello everyone
I have this code that hide rows in column G if cell has zero value or cell was empty
It is working well .. but I am searching for compact code .. or say another sub with parameters that I can call from any other sub
Thanks advanced for help
I have this code that hide rows in column G if cell has zero value or cell was empty
Code:
Private Sub CommandButton1_Click()
Dim Rng As Range
CommandButton1.Caption = IIf(CommandButton1.Caption = "Hide", "Show", "Hide")
Application.ScreenUpdating = False
On Error Resume Next
With ActiveSheet
.AutoFilterMode = False
.Range("A3:I3").AutoFilter Field:=7, Criteria1:="=0", Operator:=xlOr, Criteria2:=""
Set Rng = .Range("G4:G" & .Cells(Rows.Count, "G").End(xlUp).Row).SpecialCells(xlCellTypeVisible)
.AutoFilterMode = False
If CommandButton1.Caption = "Hide" Then
Rng.EntireRow.Hidden = False
Else
Rng.EntireRow.Hidden = True
End If
End With
Application.ScreenUpdating = True
End Sub
It is working well .. but I am searching for compact code .. or say another sub with parameters that I can call from any other sub
Thanks advanced for help