I tried it in xl2007 using code below and it worked fine!
Sub ConditionalFormatting()
Dim lngdeptlastrow As Long
With ActiveSheet
lngdeptlastrow = .Cells(Rows.Count, "A").End(xlUp).Row
' highlight late dates red
With .Range("L5:L" & lngdeptlastrow)
.FormatConditions.Delete
.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess,
Formula1:="=TODAY()"
.FormatConditions(1).Interior.ColorIndex = 3
End With
' highlight everyother row light green
With .Range("A5:O" & lngdeptlastrow)
.FormatConditions.Add Type:=xlExpression,
Formula1:="=MOD(ROW(),2)=0"
.FormatConditions(2).Interior.ColorIndex = 35
End With
End With
End Sub
--
Regards,
Nigel
"RyanH" wrote in message
...
This code is giving me fits and I can't see what the problem is. It is
probably obvious, but I'm so fustrated I can't see it. I am getting an
error
below can someone tell me why? I am wanting to highlight every other row.
ERROR: Application Defined or Object Error
Sub ConditionalFormatting()
lngDeptLastRow = .Cells(Rows.Count, "A").End(xlUp).Row
' highlight late dates red
With .Range("L5:L" & lngDeptLastRow)
.FormatConditions.Delete
.FormatConditions.Add Type:=xlCellValue,
Operator:=xlLess, Formula1:="=TODAY()"
.FormatConditions(1).Interior.ColorIndex = 3
End With
' highlight everyother row light green
With .Range("A5:O" & lngDeptLastRow)
ERROR .FormatConditions.Add Type:=xlExpression,
Formula1:="=MOD(ROW(),2)=0"
.FormatConditions(2).Interior.ColorIndex = 35
End With
End Sub
--
Cheers,
Ryan