more than 4 color choses for cell/colum

  • Thread starter Thread starter jladika
  • Start date Start date
J

jladika

I an new to excess so please show me how this is to be done
I would like to put a letter in a cell but all in the same colum.
"A" and get a color ( dont matter what color )
"B" and get a color ( dont matter what color )
"C" and get a color ( dont matter what color )
"D" and get a color ( dont matter what color )
"E" and get a color ( dont matter what color )
thanks


(e-mail address removed)


jo
 
Joe

As Frank points out, you would need VBA code.

Copy/paste this code to your worksheet.

Option Compare Text
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Num As Long
Dim rng As Range
Dim vRngInput As Variant
Set vRngInput = Intersect(Target, Range("A:A"))
If vRngInput Is Nothing Then Exit Sub
On Error GoTo endit
Application.EnableEvents = False
For Each rng In vRngInput
'Determine the color
Select Case rng.Value
Case Is = "A": Num = 10 'green
Case Is = "B": Num = 1 'black
Case Is = "C": Num = 5 'blue
Case Is = "D": Num = 7 'magenta
Case Is = "E": Num = 46 'orange
Case Is = "F": Num = 3 'red
End Select
'Apply the color
rng.Interior.ColorIndex = Num
Next rng
endit:
Application.EnableEvents = True
End

Right-click on the sheet tab and "View Code".

Paste the code into that sheet module.

Note: the range is column A. Adjust to suit.

If new to VBA and code, see David McRitchie's "getting started" site.

http://www.mvps.org/dmcritchie/excel/getstarted.htm

Gord Dibben Excel MVP
 
Back
Top