change color of a cell based on drop down selection

js1537

New member
Joined
Aug 30, 2014
Messages
3
Reaction score
0
Points
0
Hi

In cell a1 we have drop down selection(black, white, red and blue). If i select black then color of cell b1 should be black and if selection is red then cell color of b1 should be red and so on.
Please assist on above query.
 
The easiest is to
1: Set a named range to a list of colours
2: Set the OnChange event for that column (or range)

Have a look at http://www.cpearson.com/excel/colors.aspx

Assuming you have not set your default colour pallet then this should work
Pallet is: Black, White, Red, Green, Blue, Yellow, Magenta, Cyan

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then Target.Interior.ColorIndex = Application.Match(Target.Value2, Range("colours"), 0)
End Sub

Otherwise have an array of RGB and lookup the colour in the array.
 
Back
Top