Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default IF (xORy) AND (xORy)...?

If (.Cells(iRow, 1).Interior.ColorIndex = 6 OR _
.Cells(iRow, 1).Value = "") And _
(.Cells(iRow, 2).Interior.ColorIndex = 6 OR _
.Cells(iRow, 2).Value = "") Then

--
Regards,
Tom Ogilvy





"markx" wrote:

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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 11:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"