Thread: Cell fill color
View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Cell fill color

One cell.........multiple conditions?

Don't use CF, try event code.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Num As Long
With Me.Range("A1")
If IsNumeric(.Value) Then
Select Case .Value
Case Is <= 0: Num = 4 'bright green
Case 0 To 5: Num = 6 'yellow
Case 6 To 10: Num = 5 'blue
Case 11 To 15: Num = 7 'magenta
Case 16 To 20: Num = 46 'orange
Case Is 20: Num = 3 'red
End Select
End If
Sheets("Sheet1").Range("B1").Interior.ColorIndex = Num
End With
End Sub

This code will be placed in Sheet2 and will color A1 of Sheet1

Right-click on the Sheet2 tab and "View Code". Copy/paste into that sheet
module. Adjust cell refs and Case limits to suit.

Gord

On Sat, 29 Mar 2008 17:36:00 -0700, Mir Khan
wrote:

Thanks for the quick response...

Hi Gordon conditional formatting worked good for me but it has limit of 3
conditions and i have more than 3 conditions to use. Is there any other
alternative.

I appreciate your help.

Thanks

Mir Khan

"Gord Dibben" wrote:

You can do this with Conditional Formatting if you create a name for the sheet
two cell.

With Sheet two selected.

InsertNameDefine

myname......refers to: =Sheet2!D5

Then in Sheet one CFFormula is: =myname123


Gord Dibben MS Excel MVP

On Sat, 29 Mar 2008 16:04:00 -0700, Mir Khan
wrote:

Hi Experts need your help...
I need to change the cell fill color (in a cell in sheet one) based on the
cell value (in a cell in sheet two).

Thanks

Mir Khan