View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.programming
Harold Good Harold Good is offline
external usenet poster
 
Posts: 81
Default code to hide rows based on criteria - but without looping

Thanks for this Phil, I see this will avoid unnecessary looping which would
be helpful. So many different ways to do these things!

I'll wait to see if anyone can help with the SpecialCells track I was
pursuing.

Harold



"Phil Hibbs" wrote in message
...
This will select from F9 downwards to the end of the contiguous set of
non-blank cells:

Private Sub Worksheet_Calculate()
Dim cells As Range
Dim cell As Range
Application.EnableEvents = False
Range("F9").Select
Selection.End(xlDown).Select
For Each cell In Range("F9:F" & Trim(Selection.Row))
If cell.Value = "" Then
cell.EntireRow.Hidden = True
End If
Next cell
Application.EnableEvents = True
End Sub

I think the solutions posted by others are superior, but I thought
this was an interesting way of avoiding processing blank rows if you
do need to do something more complex that needs a loop.

Phil Hibbs.