Multiple Conditional formats
You're headed in the right direction. As you said, Right-click on Team8 tab
and select view code, then paste this into it:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim anyRange As Range
Dim selectedColor As Integer
If Target.Column < 4 Or Target.Cells.Count 1 Then
Exit Sub ' not in column D or multiple cells chosen (as in deleted)
End If
If IsEmpty(Target) Then
'reset if contents deleted
selectedColor = xlNone
Else
Select Case Target
Case Is < 0
'otherwise negative #s are green
selectedColor = xlNone
Case Is <= 10
selectedColor = 4 ' Green
Case Is <= 20
selectedColor = 41 ' Blue
Case Is <= 30
selectedColor = 3 ' Red
Case Is <= 40
selectedColor = 6 ' Yellow
Case Is <= 50
selectedColor = 45 ' Orange
Case Else
selectedColor = xlNone '
End Select
End If
Set anyRange = Union(Range("B" & Target.Row & ":E" & Target.Row), _
Range("Q" & Target.Row & ":U" & Target.Row))
anyRange.Interior.ColorIndex = selectedColor
End Sub
You didn't say what to do if values were less than zero or greater than 50,
so I've set things up that in those instances, previous coloring is removed.
"Gunjani" wrote:
Hi
I would like to create the following....
In Column D if cell value is between 0 and 10 then its row in column
B, C, D, E and F should be green;
In Column D if cell value is between 11 and 20 then column B, C, D, E
and F of the same row should be blue;
In Column D if cell value is between 21 and 30 then column B, C, D, E
and F of the same row should be red;
In Column D if cell value is between 31 and 40 then column B, C, D, E
and F of the same row should be yellow;
In Column D if cell value is between 41 and 50 then column B, C, D, E
and F of the same row should be orange;
etc
The same rule to apply for Columns Q, R,S, T and U
The worksheet is called 'Team 8'
I'm assuming this can only be performed in Macros so how do I begin?
Right click on Team 8 worksheet tab select 'View Code' and then I'm
unsure what to enter after that?
Can some one assist
Gunjani
|