View Single Post
  #13   Report Post  
Posted to microsoft.public.excel.misc
Otto Moehrbach
 
Posts: n/a
Default Adding colours as a function

My mistake. If the cell value is 0, the color index will be xlNone. Otto
"Otto Moehrbach" wrote in message
...
Josh
The macro I wrote for Billjary checks for the "Value" of "Target".
Target is the range of cells that were changed. Target can be multiple
cells, yes, but multiple cells do not have a "Value". That's why you get
the error.
To account for changing multiple cells at once, the macro will need to
be changed. Try the following. This will work with one cell as well as
multiple cells. "AColor" is the color index that you want for the
condition.
Note that this macro is triggered by a change in the contents of a cell in
Column G.
As written, this macro looks at each cell in the range Target. If the
value is zero (includes blank) the color index will be 1. If the value is
<25, the color index is 3. And so forth. HTH Otto
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Range
Dim AColor As Long
If Target.Column = 7 Then
For Each i In Target
Select Case i.Value
Case 0: AColor = xlNone
Case Is < 25: AColor = 1
Case Is < 50: AColor = 3
Case Is < 75: AColor = 5
Case Is < 100: AColor = 7
Case Is < 125: AColor = 9
Case Is < 150: AColor = 11
Case Is < 175: AColor = 13
End Select
i.EntireRow.Interior.ColorIndex = AColor
Next i
End If
End Sub
"Josh" wrote in message
...
I can only set 3 conditions w/ conditional formating but I need 7
different
colors.

Josh

"BruceP" wrote:


Another possibility (without using VBA) is to select the row, then go to
conditional formatting. Then use "formula is"
=ISNUMBER(FIND("0",-absolute cell reference---)). Then Format,
Patterns, choose your color.


--
BruceP
------------------------------------------------------------------------
BruceP's Profile:
http://www.excelforum.com/member.php...o&userid=33653
View this thread:
http://www.excelforum.com/showthread...hreadid=529793