Multi Conditional Formats - Still Stuck (Dave Hawley)
Posted by Sam Brown on May 25, 2001 6:13 AM
I had this bit of code(see below) from Dave Hawley (thanks) to allow multi conditonal formats, but i'm a little confused on how to code what i need.
The code selects a1:c100 (which contains numbers 1-200), I want to be able to color the cells containing "25", "37", "98", "175" & "196". So all instances of 25 will be red, all 37's will be blue, etc etc.
I'm confused on how the below code should be coded?? Any help would be great.
<code>
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim rWatchrange As Range
'Written by OzGrid Business Applications
'www.ozgrd.com
'''''''''''''''''''''''''''''''''''''''
'Allows more than 3 Conditional Formats
''''''''''''''''''''''''''''''''''''''''
If Target.Cells.Count > 1 Then Exit Sub
Set rWatchrange = Range("A1:C100")
On Error Resume Next
If Intersect(Target, rWatchrange) Is Nothing Then
Set rWatchrange = Nothing
Exit Sub
End If
Select Case Target
Case 1 To 5
Target.Interior.ColorIndex = 6
Case 6 To 10
Target.Interior.ColorIndex = 46
Case 11 To 15
Target.Interior.ColorIndex = 5
End Select
End Sub