hide zero rows / shadwe every other visible

S

Steve

Hi everyone. I found this code on the newsgroup from Tom Ogilvy. The
hidig of the cells workd great, but I can't seem to get the shading of
every other visible row. Any ideas what I'm doing wrong? Thanks!

Dim Cell As Range
Dim i As Long
Set Sh = ActiveSheet
Application.ScreenUpdating = False
With Sh
'----------Hide rows where B's value is zero----------
.Range("A7:L160").Interior.ColorIndex = xlNone
i = 1
For Each Cell In .Range("B7:B160")
If Cell.Value = 0 Then
Cell.EntireRow.Hidden = True
Else
Cell.EntireRow.Hidden = False
If i = 1 Then
Cell.Offset(0, -1).Resize(1, 11). _
Interior.ColorIndex = 37
End If
i = (i + 1) Mod 2


End If
Next Cell
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top