View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
markx markx is offline
external usenet poster
 
Posts: 60
Default IF (xORy) AND (xORy)...?

Hi guys,

I'm using the following code in order to hide the rows where both column A
and B are with yellow background:
---------------
Sub RowHide()

Application.ScreenUpdating = False

Dim iRow As Long
Dim maxRows As Long

maxRows = Range("$A$1").CurrentRegion.Rows.Count
With Worksheets(ActiveSheet.Name)
For iRow = 1 To maxRows
If .Cells(iRow, 1).Interior.ColorIndex = 6 _
And .Cells(iRow, 2).Interior.ColorIndex = 6 _
Then
.Rows(iRow).Hidden = True
End If
Next iRow
End With

Application.ScreenUpdating = True

End Sub
---------------

I would like however to expand this code a bit and add, somewhere/somehow,
an additional condition:

Here is some pseudo-code I'm trying to implement:
If . (Cells(iRow, 1).Interior.ColorIndex = 6 OR
Cells(iRow, 1).Value = "")
And . (Cells(iRow, 2).Interior.ColorIndex = 6 _ OR
Cells(iRow, 2).Value = "")
so that the rows where one of the cells (column 1 or 2) is blank are also
hidden...

Furthermore, maybe you know the way to simplify the code (or to generalize
it so that it'll still stay as it is, even if I expand the analysis from 2
columns to 100 :-))?

Thanks a lot for any hints on this,
Regards,
Mark