Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Setup / July 2009

Tip: Looking for answers? Try searching our database.

Adding color to drop down box

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Devo - 01 Jul 2009 19:30 GMT
I have a spreadsheet where I keep track of the skill level of employees.  
They can select from None, Beginner, Intermediate, Advanced and Expert.  I
would like the text color to be different for each selection so that when I
look at the results if i am trying to find all those that have indicated
expert for a particular product I just need to look for the color.

i tried using conditional formatting but it only gives you 3 conditions and
when I tried to copy it for each person, the formula would.  Hen even when I
tried changing another column manually it kept changing back to the original
formula I setup.

Thanks
Gord Dibben - 04 Jul 2009 00:19 GMT
Right-click on the sheet tab and "View Code"

Copy/paste the code below into that module.

Edit the range to suit.

Alt + q to return to Excel.

Option Compare Text
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "H1:H10"    '<=== change to suit

   check_words = Array("advanced", "expert", "beginner", _
                                   "none",  "intermediate")
   On Error GoTo ws_exit:
   Application.EnableEvents = False
   If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
       With Target
           For i = LBound(check_words) To UBound(check_words)
           If InStr(1, .Value, check_words(i)) Then
               Select Case i + 1
                   Case 1: .Interior.ColorIndex = 3    'red
                   Case 2: .Interior.ColorIndex = 6    'yellow
                   Case 3: .Interior.ColorIndex = 5    'blue
                   Case 4: .Interior.ColorIndex = 10   'green
                   Case 5: .Interior.ColorIndex = 17   'periwinkle
               End Select
             End If
           Next i
       End With
   End If
ws_exit:
   Application.EnableEvents = True
End Sub

Gord Dibben  MS Excel MVP

>I have a spreadsheet where I keep track of the skill level of employees.  
>They can select from None, Beginner, Intermediate, Advanced and Expert.  I
[quoted text clipped - 8 lines]
>
>Thanks
Devo - 06 Jul 2009 14:38 GMT
Thanks, it worked great.

Two other questions I thought you may be able to answer.

Where do you find the color index numbers?  I have tried searching for it
and couldn't find anything.

Also, is there a way to change the code so that you change the color of the
text rather than of the cell?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.