Colour Drop down list

brayleyboy

Board Regular
Joined
Nov 24, 2005
Messages
52
Is it possible to create a dropdown list in a cell(s) whereby you can select a colour to fill the cell? I have Ecel 97 RS-2 and have been trying to do this for ages!
 

Some videos you may like

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

brayleyboy

Board Regular
Joined
Nov 24, 2005
Messages
52
Its for filling in project status on a gantt chart style table. It is purely to make it simpler for the user and reduce human error by being able to select it in the cell. Is there any way of doing this. Conditional formatting would enable a choice of three colours, but i need 5.
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Make a list of coulours like this:

Red
Green
Blue
Yellow
Brown

and name it List using Insert|Name|Define.

Select the cells you want to colour and choose Data|Validation from the menu. In the Allow box choose List. In the Source box type:

=List

and click OK.

Right click the sheet tab and choose View Code. Paste this code into the window on the right:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    MsgBox "Hello"
    Dim Temp As String
    On Error Resume Next
    Temp = Target.Validation.Formula1
    If Err <> 0 Then Exit Sub
    Select Case Target.Value
        Case "Red"
            Target.Interior.ColorIndex = 3
            Target.Font.ColorIndex = 3
        Case "Green"
            Target.Interior.ColorIndex = 10
            Target.Font.ColorIndex = 10
        Case "Blue"
            Target.Interior.ColorIndex = 5
            Target.Font.ColorIndex = 5
        Case "Yellow"
            Target.Interior.ColorIndex = 6
            Target.Font.ColorIndex = 6
        Case "Brown"
            Target.Interior.ColorIndex = 53
            Target.Font.ColorIndex = 53
    End Select
End Sub

Press Alt+F11 to return to your worksheet and try it out.
 

brayleyboy

Board Regular
Joined
Nov 24, 2005
Messages
52
This does not seem to work. When you select an option from the dropdown list nothing happens except it enters the word "red" etc in a black font. If you type the words "red" etc in rather than using the dropdown it brings up a nice box that says "hello", however the formatting is not changed.
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,047
Office Version
  1. 365
Platform
  1. Windows
brayleyboy

Like I said in your other post, as far as I know, a selection from a validation dropdown won't trigger a worksheet change event in earlier versions of Excel.
 

Watch MrExcel Video

Forum statistics

Threads
1,118,069
Messages
5,570,009
Members
412,304
Latest member
citrus
Top