Thread: How to do this:
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Mike Fogleman Mike Fogleman is offline
external usenet poster
 
Posts: 1,092
Default How to do this:

Keep in mind that a max of 3 conditions can be used:

With Selection
.FormatConditions.Delete
.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="1"
.FormatConditions(1).Interior.ColorIndex = 3 'red
.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="2"
.FormatConditions(2).Interior.ColorIndex = 41 'blue
.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="3"
.FormatConditions(3).Interior.ColorIndex = 4 'green
End With

Mike F
"Tim" wrote in message
...
I need to format a range of cells, to be red if the cell
value is 1, blue if the cell value is 2 etc etc

I'll have to do this on differnet ranges, so I'm looking
for a way to apply the above formatting to whatever the
current users selection of cells is.

something like
range = current selection of cells
if cell in range = 1 then (format option)
if cell in range = 2 then (next format option

Something like that
TIA
Tim