Hide/Unhide rows based on more than one cell value
- by Mike
Please help me
I am using the following code to hide rows if cell values are 0:
Private Sub Worksheet_Calculate()
Dim LastRow As Long, c As Range
Application.EnableEvents = False
LastRow = Cells(Cells.Rows.Count, "I").End(xlUp).Row
On Error Resume Next
For Each c In Range("I9:I48")
If c.Value = 0 Then
c.EntireRow.Hidden = True
ElseIf c.Value > 0 Then
c.EntireRow.Hidden = False
End If
Next
On Error GoTo 0
Application.EnableEvents = True
End Sub
It works perfectly, but I would like for the code to also check column K (the same range K9:K48) if both cells in a row are 0 then the row must be hidden. How can I change the code to do this?