View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
lost!! lost!! is offline
external usenet poster
 
Posts: 8
Default Conditional Formatting in a Loop

Hi there,

I'm trying to use a loop to copy a conditional format from row to row. The
conditional format is to compare row A### to the row above and the row below
- if a duplicate is found then the colour should change.
The next part is to compare the value in D## to F## and if the result is not
the same the colour should change. Here is the code I have used (it's very
simple since I'm just new at programming):

' check to see if row is equal to row above or below
'
Range("A26").Select
While ActiveCell.Value < ""
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$A$26 =
$A$27"
Selection.FormatConditions(1).Interior.ColorIndex = 35
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="$A$27 =
$A$28"
Selection.FormatConditions(2).Interior.ColorIndex = 35
'
' check to see if rate charged was incorrect - compare d & f
'
ActiveCell.Offset(0, 3).Range("A1:C1").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=$D26<$F26"
Selection.FormatConditions(1).Interior.ColorIndex = 39
ActiveCell.Offset(1, -3).Range("A1").Select
Wend

I have tried removing the $ from the format but that didn't help either.

The format is copying but only looking at the data in row 26.

Please help!!!