Thats' very surprising. I went and tested this on a Excel 2000/win2k
machine abd it worked just fine, all solutions proffered did. Here is
the code I used, with various versions commented out:
Sub blah()
sgR = "R"
sgC = "C"
cgDQ = """"
Range("D6").Select
ActiveCell.Offset(0, 6).FormulaR1C1 = _
"=if(" & sgR & sgC & "[-2]=" & sgR & sgC & "[-1]" _
& "," & cgDQ & cgDQ _
& "," & sgR & sgC & "[-2] -" & sgR & sgC & "[-1])"
'With ActiveCell.Offset(0, 6) 'Lisa's original
'.FormatConditions.Delete
'.FormatConditions.Add _
'Type:=xlCellValue, _
'Operator:=xlNotEqual, _
'Formula1:=cgDQ & cgDQ
'.FormatConditions(1).Font.ColorIndex = 3
'.FormatConditions(1).Interior.ColorIndex = 6
'End With
'With ActiveCell.Offset(0, 6) 'my 1st offering
'.FormatConditions.Delete
'.FormatConditions.Add _
' Type:=xlExpression, _
' Formula1:="=LEN(INDIRECT(ADDRESS(ROW(),COLUMN())))"
'.FormatConditions(1).Font.ColorIndex = 3
'.FormatConditions(1).Interior.ColorIndex = 6
'End With
'With ActiveCell.Offset(0, 6) 'my 2nd offering
'.FormatConditions.Delete
'.FormatConditions.Add _
' Type:=xlExpression, _
' Formula1:="=len(" & .Address & ")"
'.FormatConditions(1).Font.ColorIndex = 3
'.FormatConditions(1).Interior.ColorIndex = 6
'End With
With ActiveCell.Offset(0, 6) 'David's solution
.FormatConditions.Delete
.FormatConditions.Add _
Type:=xlCellValue, _
Operator:=xlNotEqual, _
Formula1:="=" & cgDQ & cgDQ
.FormatConditions(1).Font.ColorIndex = 3
.FormatConditions(1).Interior.ColorIndex = 6
End With
End Sub