View Single Post
  #17   Report Post  
Posted to microsoft.public.excel.programming
Dana DeLouis Dana DeLouis is offline
external usenet poster
 
Posts: 947
Default Worksheet_Calculate with no effect

ElseIf rang = -1 And rang < -0.8 Then
rang.Interior.ColorIndex = 11
ElseIf rang = -0.8 And rang < -0.6 Then
rang.Interior.ColorIndex = 5
ElseIf rang = -0.6 And rang < -0.4 Then
rang.Interior.ColorIndex = 41
etc....


In addition, you have a long list of IF Statements:
One of a few options is to break the range of values into intervals.
Once you've numbered your intervals, you then convert. I've used Mod for
the conversion to your ColorIndex values.
Here's one idea;

Select Case Rang.Value
Case Is < -1, Is = 1
'Do Nothing
Case Is < 0
x = -10 * WorksheetFunction.Ceiling(Rang, -0.2)
Rang.Interior.ColorIndex = 45689081 Mod (x + 39)
Case 0 To 1
x = 10 * WorksheetFunction.Floor(Rang, 0.2)
Rang.Interior.ColorIndex = 2715183 Mod (x + 47)
End Select

--
HTH :)
Dana DeLouis
Windows XP & Excel 2007


"Dana DeLouis" wrote in message
...
Not sure, but I think your two blocks of code are similar. Would this
idea help?

For Each Rang In Range("P6:S6,P10:S10").Cells
'Your code listed here once.
Next Rang

--
Dana DeLouis

<snip