View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Patrick Molloy[_2_] Patrick Molloy[_2_] is offline
external usenet poster
 
Posts: 1,298
Default Hide Entire Rows Range

the code says hide if any cell contains the word.
You can easily alter this to that if any cell doesn't contain the word that
the row gets hidded...but I agree with p45cal that that seems odd.

"Patrick Molloy" wrote:

checking every cell in a row is OTT for this. Every developer will have his
own method

I show the same using FIND in my code, but you could use the COUNTIF()
function too
if the count is zero, hide the row.


Sub hideRows()
Dim rw As Long
Dim c As Long
On Error Resume Next
For rw = 23 To 25
'If Range(rw).Find("minumum") Is Nothing Then
c = WorksheetFunction.CountIf(Rows(rw), "minimum")
If c = 0 Then
If Err.Number < 0 Then
Rows(rw).Hidden = True
Err.Clear
End If
End If
Next
End Sub

"QuickLearner" wrote:

Hi At the moment I have this code to hide entire row
and it is working fine.


Sub HideRows()
Dim MyRange As Range, cl As Range

Set MyRange = Sheet3.Range("A23:IV25")
Application.ScreenUpdating = False
For Each cl In MyRange
If cl.Value < "Minimum" Then cl.EntireRow.Hidden = True
Next cl
Application.ScreenUpdating = True
End Sub


Now another question is
How can I hide the Entire Range("A23:IV25") if the Value is "Minimum"?

Thanks