Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
kennethwt
 
Posts: n/a
Default automatic color change in cells using a drop down list

How do I get the colors to change automatically when I use a drop down list.
Per say here is what I am trying to do

If a certain "word" is used from the drop down list I want the background of
that cell to change its color to "green." And if later I change the "word" to
another from the drop down list, it will change it's color to a specified
color.

The drop down list that I use was created from cells that have the colors
already in the "word", but I do not know how to make the list show the colors
so it puts the word & color automatically in the drop down list to the cell
with the drop down (if that makes any sense).

If there is a way, please spell it out simple enough for me to understand,
as I don't know fully the capabilities of formulas or vba.
  #2   Report Post  
Gord Dibben
 
Posts: n/a
Default

ken

You could use Conditional Formatting to color the cell based on the "word"
entered.

However this gives you 4 choices only, including the default "no color".

For more you would need VBA event code.

Example below. Adjust range and A, B, C etc. to suit.

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("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 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 Sub

This code wopuld be copy/pasted to a worksheet module.

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


Gord Dibben Excel MVP

On Thu, 20 Jan 2005 20:53:01 -0800, kennethwt
wrote:

How do I get the colors to change automatically when I use a drop down list.
Per say here is what I am trying to do

If a certain "word" is used from the drop down list I want the background of
that cell to change its color to "green." And if later I change the "word" to
another from the drop down list, it will change it's color to a specified
color.

The drop down list that I use was created from cells that have the colors
already in the "word", but I do not know how to make the list show the colors
so it puts the word & color automatically in the drop down list to the cell
with the drop down (if that makes any sense).

If there is a way, please spell it out simple enough for me to understand,
as I don't know fully the capabilities of formulas or vba.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
drop down list c Excel Discussion (Misc queries) 10 January 17th 05 11:29 PM
How to change fonts in drop down list Dennis Excel Discussion (Misc queries) 1 January 12th 05 01:49 PM
Drop Down List Sandy Excel Worksheet Functions 3 January 11th 05 10:50 PM
formatting drop down list dennis Excel Discussion (Misc queries) 2 January 11th 05 04:21 PM
Drop List Referencing Boony Excel Worksheet Functions 2 November 11th 04 11:42 AM


All times are GMT +1. The time now is 05:57 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"