下面的程序目的:使得如图说示的图表根据值的大小相应的改变颜色,
这是一段宏的程序,指定在右面那个图的下拉框上,
具体是在report-by-dept 的右面那个图, 当选择EDM, 再选择2006-10月到 2006-11月时,图标的颜色不对了,有时候都是一红一绿, 有时候都是红色, 很是奇怪,, 按例应该都是绿色的,应为都小于90%,但多试几次有时候又会对,,,,到底错在什么地方呢?? 是不是把这段宏指定在UPDATE这个按钮上呢,不过,我试过似乎不可以,
请大虾诊断,,,,,
Sub Chartcolor1()
' if the cell value<90% green
' if the cell value 90%~105% yellow
' if the cell value >105% red
Dim ICol, JCol As Integer
Dim myRange, CRange As Range
Set myRange = ActiveSheet.Range("A21:BC21")
ICol = Application.WorksheetFunction.Match(Range("N26"), myRange)
JCol = Application.WorksheetFunction.Match(Range("26"), myRange)
Set CRange = Range(ActiveSheet.Cells(22, ICol), ActiveSheet.Cells(22, JCol))
i = 1
ActiveSheet.ChartObjects(2).Activate
With ActiveChart.SeriesCollection(1)
For Each CEL In CRange 'Range("b22:bc22")
Select Case CEL.Value
Case Is < 0.9
.Points(i).Interior.ColorIndex = 4
Case 0.9 To 1.05
.Points(i).Interior.ColorIndex = 27
Case Is > 1.05
.Points(i).Interior.ColorIndex = 3
End Select
i = i + 1
Next
End With
End Sub
[
[此贴子已经被作者于2006-10-26 21:24:56编辑过]
|