View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default how do i get more than 3 colours in conditional formatting

Run this macro.

Sub ListColorIndexes()
Dim Ndx As Long
Sheets.Add
For Ndx = 1 To 56
Cells(Ndx, 1).Interior.ColorIndex = Ndx
Cells(Ndx, 2).Value = Hex(ThisWorkbook.Colors(Ndx))
Cells(Ndx, 3).Value = Ndx

Next Ndx

End Sub


Gord Dibben MS Excel MVP

On Thu, 24 Apr 2008 06:37:16 -0700, Nicole
wrote:

Thanks Bob - this is great!

Just one more thing, if i want to change the colours how do I know which
colour code it is?

"Bob Phillips" wrote:


'-----------------------------------------------------------------
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 "R": .Interior.ColorIndex = 3 'red
Case "A": .Interior.ColorIndex = 6 'yellow
Case "C" .Interior.ColorIndex = 5 'blue
Case "I": .Interior.ColorIndex = 10 'green
'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


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Nicole" wrote in message
...
I have tried to download bob's add in but this comes up with an error.

I need a code to show different colours when I type R, A, C, I, RA. I
have
tried using the code written which seems to work fine for numbers but not
text...HELP!