Color color! Cell color!

  • Thread starter Thread starter mhax
  • Start date Start date
M

mhax

hi

i've got two range : ("C5:N35" that contain data) and ("P5:AA35" that
will have different color depending on user inupt)!

There is 6 different colors(so NO i CANT USE conditionnal formating), i
want something in vb, macro for excel 2002!

So here an example : If in cell P10, the user put the letter N, the
cell become red. It will also change the cell color in C10. Can you
guys help me?

Thanks in advance!

Maxime
 
Something like

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "H1:H10"


On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
Select Case .Value
Case "N": .Interior.ColorIndex = 3 'red
Case "X": .Interior.ColorIndex = 6 'yellow
Case "Y": .Interior.ColorIndex = 5 'blue
Case "G": .Interior.ColorIndex = 10 'green
End Select
End With
End If


ws_exit:
Application.EnableEvents = True
End Sub


'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)
 
Back
Top