More Efficient code than this
I am a bit confused by what is going on here. You unhide hidden rows, but
exit if there were any, then you hide rows with x x in? Is that right?
--
HTH
Bob Phillips
"thom hoyle" wrote in message
...
Here is a piece of code I'm using to hide rows that have an "x" in two of
the
columns. Is there a more efficient way to write this.
thanks
Sub HideRows()
Application.ScreenUpdating = False
Dim rng As Range
Dim i As Long
Set rng = Range("E5:E204")
i = 0 'set up a variable to see if range contains hidden rows
For Each c In rng
If c.EntireRow.Hidden = True Then
c.EntireRow.Hidden = False
i = 1
End If
Next
If i = 1 Then 'if any hidden rows unhide
Application.ScreenUpdating = True
Exit Sub
End If
For Each c In rng 'if no hidden rows unhidden then hide
If c.Value = "x" And c.Offset(0, 3).Value = "x" Then
c.EntireRow.Hidden = True
End If
Next
Application.ScreenUpdating = True
End Sub
|