View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JE McGimpsey JE McGimpsey is offline
external usenet poster
 
Posts: 4,624
Default Change colour of cells depending on entry in one cell

One way:

Assuming your column Fvalues are entered manually, put this in your
worksheet code module (right-click the worksheet tab and choose View
Code):

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim rArea As Range
Dim rCell As Range
Dim nColor As Long
Set Target = Intersect(Target, Range("F:F"))
If Not Target Is Nothing Then
For Each rArea In Target
For Each rCell In rArea
Select Case rCell.Value
Case 0, 100
nColor = RGB(255, 0, 0)
Case 30
nColor = RGB(0, 0, 255)
Case 60
nColor = RGB(255, 102, 0)
Case 90
nColor = RGB(0, 255, 0)
Case Else
nColor = -1
End Select
If Not nColor = -1 Then _
rCell.Offset(0, -5).Interior.Color = nColor
Next rCell
Next rArea
End If
End Sub


In article ,
harwookf wrote:

In one column (F), I have data like 0, 10, 30, 60, 90 and 100. I need to
change the background colour of another column (B) depending on what the
entry is in column F.

e.g. f2 = 0 or 100 then a2 = red, 30 = blue, 60 = orange, 90 = green, 10 =
no change