Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Filtering and Conditional Formatting 1

Status
Not open for further replies.

Crystalyzer

Technical User
Mar 28, 2003
218
0
0
I have data which I have conditionally formatted so that every other line will have a green shade. I used the formula...

=MOD(ROW(),2)

... in the conditional format field, however, when I filter the data the some rows are hidden and some not which causes lines that appear to be one after another having the same shading or non shading. Is there a way to conditionally format the rows so that the displayed rows will alternate the shading properly?

Thanks in advance for any help.

Lloyd
 
Sorry, forgot to say I am using Excel 2003.

Thanks
 
I think you're going to need a macro to do this. When the macro runs, it will have to apply the formatting to every other VISIBLE row.

Frank kegley
fkegley@hotmail.com
 
right you are Frank and here's how I did it for those interested.

Code:
Private Sub Worksheet_Calculate()
Range("Start").Select
  j = 1
  k = 0
  For j = 1 To Range("Query_from_Investran").Rows.Count - 1
    If Range("Start").Offset(j, 0).EntireRow.Hidden = False Then
      k = k + 1
      Selection.Offset(1, 0).Select
      If k = 1 Then
      Range(Selection, Selection.Offset(0, Range("Query_from_Investran").Columns.Count - 1)).Select
      End If
      If k Mod 2 = 0 Then
        With Selection.Interior
          .ColorIndex = 35
          .Pattern = xlSolid
        End With
      Else
        Selection.Interior.ColorIndex = xlNone
      End If
    End If
  Next j
  Range("Start").Select
End Sub

Wish I could give myself a star LOL
 
Crystalyzer,

Thanks for posting your solution to your own question. While my needs were not quite the same as yours I was able to find my way based on some of the ideas presented in your code.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top