Thread: Colouring cells
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Colouring cells

Option Explicit

Sub ColorSelection()
Dim varr As Variant
Dim cell As Range
varr = Array(3, 6, 8, 20, 15) ' array of color indexes corresponding to
number 1 to 5
For Each cell In Selection
If IsNumeric(cell.Value) Then
If CLng(cell.Value) = 1 And CLng(cell.Value) <= 5 Then
cell.Interior.ColorIndex = varr(CLng(cell.Value) + (LBound(varr) =
0))
End If
End If
Next
End Sub


--
Regards,
Tom Ogilvy



"Sam A" wrote in message
...
As you can only do 3 conditional formats - I have been
pointed to donig this is VB. Any ideas!!
I want to colour cells if the value is equal to a number -
1,2,3,4 or 5. Need to be a different colour for each
result.
thanks
Sam