View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Robert Brydges
 
Posts: n/a
Default Conditional Formatting again

The code is as follows:
Private Sub Worksheet_Calculate()

Dim oCell As Range
For Each oCell In
Range("f4:f56,i4:i56,l4:l56,o4:o56,r4:r56,u4:u56")
Select Case oCell.Value
Case Is < 1
oCell.Resize(1, 2).Interior.ColorIndex = 16
oCell.Resize(1, 2).Interior.Pattern = xlPatternSolid
Case Is = 1
oCell.Resize(1, 2).Interior.ColorIndex = 6
oCell.Resize(1, 2).Interior.Pattern = xlPatternSolid
Case Is = 2
oCell.Resize(1, 2).Interior.ColorIndex = 6
oCell.Resize(1, 2).Interior.Pattern = xlPatternGray8
Case Is = 3
oCell.Resize(1, 2).Interior.ColorIndex = 37
oCell.Resize(1, 2).Interior.Pattern = xlPatternSolid
Case Is = 4
oCell.Resize(1, 2).Interior.ColorIndex = 37
oCell.Resize(1, 2).Interior.Pattern = xlPatternGray8
Case Is = 5
oCell.Resize(1, 2).Interior.ColorIndex = 41
oCell.Resize(1, 2).Interior.Pattern = xlPatternSolid
Case Is = 6
oCell.Resize(1, 2).Interior.Color = RGB(255, 238, 130)
oCell.Resize(1, 2).Interior.Pattern = xlPatternSolid
Case Is = 7
oCell.Resize(1, 2).Interior.ColorIndex = 7
oCell.Resize(1, 2).Interior.Pattern = xlPatternGray8
Case Is = 8
oCell.Resize(1, 2).Interior.Color = RGB(70, 238, 130)
oCell.Resize(1, 2).Interior.Pattern = xlPatternSolid
Case Is = 9
oCell.Resize(1, 2).Interior.ColorIndex = 15
oCell.Resize(1, 2).Interior.Pattern = xlPatternSolid
Case Is = 10
oCell.Resize(1, 2).Interior.ColorIndex = 2
oCell.Resize(1, 2).Interior.Pattern = xlPatternSolid
Case Is < 100
oCell.Resize(1, 2).Interior.ColorIndex = 7
oCell.Resize(1, 2).Interior.Pattern = xlPatternSolid
Case Is 99
oCell.Resize(1, 2).Interior.Color = RGB(255, 70, 255)
oCell.Resize(1, 2).Interior.Pattern = xlPatternSolid
End Select
Next oCell

End Sub

It works fine if I limit it to f4:f56, and it works if I just add a
second range i4:i56, but I get the runtime error mismatch 13 when I add
the third range l4:l56 - this happens whether I do it in the form of a
single procedure or a series of 6 procedures with identical code except
for the ranges. What do you think?

Thanks,
Robert