View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default conditional formatting text


'-----------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
'-----------------------------------------------------------------
Const WS_RANGE As String = "H1:H10" '<==== change to suit

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 "cds": .Interior.ColorIndex = 5 'blue
Case "vgh": .Interior.ColorIndex = 5 'blue
Case "cda": .Interior.ColorIndex = 46 'orange
Case "khg": .Interior.ColorIndex = 46 'orange
Case "bn": .Interior.ColorIndex = 3 'red
'etc.
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 somewhere in email address with gmail if mailing direct)

"kate" wrote in message
...
Could you please help me?
I am trying to format text to highlight different colours depending on

code
e.g

cds (I would like to be blue) and vgh ( I would like to be blue)
bn (I would like to be red)
cda ( I would like to be orange) and khg (I would like to be orange)

and so on...
The data range is c1:c550 with various names
hope you can help thankyou Kate