开发者

Hiding Rows Based on Information in Two Different Columns

I need to be able to hide a row if the numbers in column "c" and in column "d" are zero. I the below code works but stops after looping through only 4 rows of data. There is nothing different between the data so I don't know why it stops. Can someone please help me? Thank you.

Sub Hide_Row_3()

' Hide_Row_3 Macro

Worksheets("Costs").Activate
Application.ScreenUpdating = False

Dim rCell As Range

For Each rCell In R开发者_如何学JAVAange("c7:c18, d7:d18")
    If rCell = 0 And rCell(xright) = 0 Then
        rCell.EntireRow.Hidden = True
    Else
        rCell.EntireRow.Hidden = False
End If

Next rCell

Application.ScreenUpdating = True

End Sub


For Each rCell In Range("c7:c18")

is enough.

Edit>

The following loop works for me"

For Each rCell In Range("c7:c18")
    If rCell = 0 And rCell.Offset(0, 1) = 0 Then
        rCell.EntireRow.Hidden = True
    Else
       rCell.EntireRow.Hidden = False
End If

HTH!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜