View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Keith Wilby Keith Wilby is offline
external usenet poster
 
Posts: 40
Default Conditional Formatting Strangeness

I'm working from an Access database to conditionally format cells in Excel.
Here's a snippet of my code. I don't pretend to understand how some of it
works, it was kindly supplied by Bernie Deitrick.

Set objRange = objXL.Intersect(objSht.Range("K2:IV65536"),
objSht.UsedRange) 'Start from Row 2
With objRange
.Select
.FormatConditions.Delete
.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess,
Formula1:="=" & .Cells(1, 0).Address(False, False)
.FormatConditions(1).Interior.ColorIndex = 3 'Conditionally
format cells red
.FormatConditions.Add Type:=xlCellValue,
Operator:=xlGreater, Formula1:="=" & .Cells(1, 0).Address(False, False)
.FormatConditions(2).Interior.ColorIndex = 4 'Conditionally
format cells red
End With

When I manually select cell K2 in Excel and look up the conditional
formatting it references cell T2 instead of cell J2. That just happens to
be an offset of 10. I'm *sure* this code used to work but I can't for the
life of me work out why it's behaving this way. Any clues anyone?

Many thanks.

Keith.