, :
Option Explicit
Sub Hide()
Application.ScreenUpdating = False
Dim wks As Worksheet
Dim Lastrow As String
Dim Rng As Range, i As Long
Dim cell As Variant
For Each wks In ThisWorkbook.Worksheets
wks.Rows.Hidden = False
Lastrow = wks.Range("H" & Rows.Count).End(xlUp).Row
If Lastrow > 1 Then
cell = wks.Range("H1:H" & Lastrow).Value
i = 1: Set Rng = Nothing
While i <= Lastrow
For i = i To Lastrow
If LCase(cell(i, 1)) = "closed" Then Exit For
Next
For i = i To Lastrow
If LCase(cell(i, 1)) = "closed" Or cell(i, 1) = "" Then
If Rng Is Nothing Then
Set Rng = wks.Rows(i)
Else
Set Rng = Union(Rng, wks.Rows(i))
End If
Else
Exit For
End If
Next
Wend
If Not Rng Is Nothing Then Rng.EntireRow.Hidden = True
End If
Next
MsgBox "All Rows containing Closed in Column H have been hidden", vbInformation, "Information"
Application.ScreenUpdating = True
End Sub
:
Option Explicit
Sub Hide()
Application.ScreenUpdating = False
Dim wks As Worksheet
Dim Lastrow As String
Dim i As Long, hideB As Boolean
Dim cell As Variant
For Each wks In ThisWorkbook.Worksheets
wks.Rows.Hidden = False
Lastrow = wks.Range("H" & Rows.Count).End(xlUp).Row
If Lastrow > 1 Then
cell = wks.Range("H1:H" & Lastrow).Value
Set Rng = Nothing: hideB = False
For i = 1 To Lastrow
If Len(cell(i, 1)) Then
'this determinates if the line will be hidden
hideB = (LCase(cell(i, 1)) = "closed")
'if you want to check G also => hideB = (LCase(cell(i, 1)) = "closed") And (LCase(wks.cells(i, "G")) = "keyword2")
End If
If hideB Then
If Rng Is Nothing Then
Set Rng = wks.Rows(i)
Else
Set Rng = Union(Rng, wks.Rows(i))
End If
End If
Next
If Not Rng Is Nothing Then Rng.EntireRow.Hidden = True
End If
Next
MsgBox "All Rows containing Closed in Column H have been hidden", vbInformation, "Information"
End Sub