Hide/Unhide rows based on more than one cell value
Posted
by
Mike
on Super User
See other posts from Super User
or by Mike
Published on 2014-05-28T08:27:16Z
Indexed on
2014/05/30
21:37 UTC
Read the original article
Hit count: 176
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?
© Super User or respective owner