Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Conditional formatting on null value

1 view
Skip to first unread message

haroon

unread,
Jun 1, 2000, 3:00:00 AM6/1/00
to

I have a cell that can have either the value 0 or 1, or have nothing in
it.

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


Ron Rosenfeld

unread,
Jun 1, 2000, 3:00:00 AM6/1/00
to
On Thu, 01 Jun 2000 05:22:02 -0400, haroon <haroon...@sympatico.ca>
wrote:

Try Formula1:=ISNULL(Selection)

HTH,

--ron

fes

unread,
Jun 1, 2000, 3:00:00 AM6/1/00
to
Haroon, if you want to format cells A1:C1 for example, you can try

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...

Tom Ogilvy

unread,
Jun 1, 2000, 3:00:00 AM6/1/00
to
You could try this:

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

0 new messages