How do I format cell on condition that it has nothing in it??
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _
Formula1:="0", Formula2:="1"
Thanks in advance,
Haroon
Try Formula1:=ISNULL(Selection)
HTH,
--ron
Range("A1:C1").FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween,
_
Formula1:="=ISBLANK(A1)"
Regards
Fred
haroon <haroon...@sympatico.ca> wrote in message
news:39362B3A...@sympatico.ca...
Sub SetFormat()
If Selection.Count = 1 Then
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, _
Formula1:="=OR(" & Selection.Address & "=0," & _
Selection.Address & "=1,LEN(TRIM(" & _
Selection.Address & "))=0)"
Selection.FormatConditions(1).Interior.ColorIndex = 36
End If
End Sub
or a more general approach that will work with a multicell selection
Sub SetFormat()
Selection.FormatConditions.Delete
sform = "=OR(" & ActiveCell.Address(False, False) & "=0," & _
ActiveCell.Address(False, False) & "=1,LEN(TRIM(" & _
ActiveCell.Address(False, False) & "))=0)"
Selection.FormatConditions.Add Type:=xlExpression, _
Formula1:=sform
Selection.FormatConditions(1).Interior.ColorIndex = 36
End Sub
Regards,
Tom Ogilvy
MVP Excel