View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default drop down list that changes cell color upon selection

Revised code.

Note the change from "interior.colorindex" to "Font.colorindex"

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Num As Long
Dim rng As Range
Dim vRngInput As Variant
Set vRngInput = Range("A1"))
If vRngInput Is Nothing Then Exit Sub
On Error GoTo endit
Application.EnableEvents = False
For Each rng In vRngInput
'Determine the color
Select Case UCase(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
Case is = "G": Num = 8 'cyan
End Select
'Apply the color
rng.Font.ColorIndex = Num
Next rng
endit:
Application.EnableEvents = True
End Sub


Gord



On Wed, 6 Feb 2008 14:43:47 -0800 (PST), wrote:

hi,
Thank you so much it indeed worked.

Is it possible to make the font color change instead of
background color of a cell in context to the above solution? Please
let know. Shall wait for your valuable inputs/suggestions in the
above

thanks,
Swarna Kumar T.S