Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]()
I want to assign a colour to a group of 4 cells (ie a1 to a4) based on the
colour that is typed into another cell (ie d1). It could be that I need the option of using 10 colours. eg if d1 was "green" then a1-a4 would be coloured green. |
#2
![]() |
|||
|
|||
![]()
Andy
For greater than 3 colors(4 if use default no color) you will need VBA. Option Compare Text Private Sub Worksheet_Change(ByVal Target As Range) Dim Num As Long Dim rng As Range Dim vRngInput As Variant Set rng1 = Intersect(Target, Range("D1")) If rng1 Is Nothing Then Exit Sub On Error GoTo endit Application.EnableEvents = False Set rng2 = Range("A1:A4") 'Determine the color Select Case rng1.Value Case Is = "green": Num = 10 'green Case Is = "black": Num = 1 'black Case Is = "blue": Num = 5 'blue Case Is = "magenta": Num = 7 'magenta Case Is = "orange": Num = 46 'orange Case Is = "red": Num = 3 'red 'add more cases as you wish End Select rng2.Interior.ColorIndex = Num endit: Application.EnableEvents = True End Sub Right-click on the sheet tab and "View Code". Copy/paste the code into that module. Note: Data ValidationList can be used to enter the value into D1. Gord Dibben Excel MVP On Tue, 6 Sep 2005 09:00:22 -0700, Andy64 wrote: I want to assign a colour to a group of 4 cells (ie a1 to a4) based on the colour that is typed into another cell (ie d1). It could be that I need the option of using 10 colours. eg if d1 was "green" then a1-a4 would be coloured green. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Is there a way to color the cells based on the numeric value? | Excel Worksheet Functions | |||
Subtract a group of cells from a total based on ending date | Excel Discussion (Misc queries) | |||
I want to format a cell based on an adjacent cells value | Excel Discussion (Misc queries) | |||
how do you format a row of cells based upon a value in another ce. | Excel Discussion (Misc queries) | |||
conditional formating - Highlighting text cells based on sales res | Excel Discussion (Misc queries) |