Cell Entry Color


Posted by hbendillo on January 07, 2002 11:12 AM

I would like to write a macro or function that compares entries in two cells and colors one of the entries red based on the result. Here is something that I came up with that does not quite work. Perhaps it will give you a better idea of what I am trying to do:

Sub Test BusSize()
BusSize=Sheet("Audit").Range("E9").Value
DemandAmps=Sheet("Audit").Range("H9").Value
If DemandAmps > BusSize Then BusSize.Interior.ColorIndex=3
Else BusSize.Interior.ColorIndex=xlnone\
EndIf

It is the entry in cell "E9" that I want to change to red, not the background color of the cell. I have to do a number of times in a chart and so will repeat the if statement for each occurence. Thanks.

Posted by Scott on January 07, 2002 12:02 PM

Try this:

Sub Test()

If Range("H9").Cells > Range("E9").Cells Then
Range("E9").Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
Else:
Range("E9").Select
Selection.Interior.ColorIndex = xlNone
End If

End Sub

Posted by Scott on January 07, 2002 12:04 PM

Typo = Change ColorIndex to 3 (NT)



Posted by Herb B. on January 07, 2002 12:58 PM

Re: Typo = Change ColorIndex to 3 (NT)

Thanks. This works.