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!
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

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,351
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.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,117
Messages
5,857,477
Members
431,882
Latest member
saaaaaaaaaaaaaaaaaaaaaa

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top