Hi Tony,
I see Norman has moved things on a bit.
2 comments
1. make sure Normans code is in the "microsoft excel objects" ... "this
workbook " section not in the "modules" section.
To avoid possible confusion, my suggested code represents worksheet event
code and, as such, should be placed in the appropriate worksheet module -
not in the workbook's ThisWorkbook module and not in a standard module. For
more explicit instructions, see my initial response to Steve (Blain).
However, in the absence of a post by Steve, and to provide a contextual
closure to the thread, the file which Steve sent me (a) relied on links to a
table in another sheet and (b) related to an extended range rather than the
single cell implied in his initial post. This being the case, I suggested
replacing my initial Worksheet_Change code with an appropriately amended
Worksheet_Calculate procedure, e.g.:
'=============>>
Private Sub Worksheet_Calculate()
Dim rng As Range
Dim rCell As Range
On Error Resume Next
Set rng = Me.Range("A1:AA23"). _
SpecialCells(xlCellTypeFormulas, xlTextValues)
On Error GoTo 0
If Not rng Is Nothing Then
For Each rCell In rng.Cells
With rCell
Select Case UCase(.Value)
Case "G": .Interior.ColorIndex = 3
Case "G/S7": .Interior.ColorIndex = 4
Case "D14": .Interior.ColorIndex = 5
Case "D15": .Interior.ColorIndex = 6
Case "D16": .Interior.ColorIndex = 7
Case "COT MIX": .Interior.ColorIndex = 8
Case "DCOT14": .Interior.ColorIndex = 9
Case "D_CPS_14": .Interior.ColorIndex = 10
Case "DCOTBB14": .Interior.ColorIndex = 11
Case "COT/CPS": .Interior.ColorIndex = 12
Case "DCOTBB15": .Interior.ColorIndex = 13
Case "DCOTBB16": .Interior.ColorIndex = 14
Case "ISCBBsales": .Interior.ColorIndex = 15
Case "ISC/CRM": .Interior.ColorIndex = 16
Case Else: .Interior.ColorIndex = xlNone
End Select
End With
Next rCell
End If
End Sub
'<<=============
As far as your second comment:
2. I don't think you would want to change the colour pallette for this
sort of use so use the RGB function rather than colourindex
is concerned, I would direct you to Tom Ogilvy's pithily pertinent response.