Interior Color painting af chart i 2010(VB7) versus 2003 (VB6)
Jeg farver barcharts i en bestem farve efter værdien:Dette kører fint som nedenstående i Excel 2003 (VB6)men hvordan klares det i 2010 (VB)?
#If VBA7 Then
Const VBATest = "VBA7"
#Else
Const VBATest = "VBA6"
#End If
Private Sub Worksheet_Calculate()
If VBATest = "VBA6" Then
color_chart
Else
?????
End If
End Sub
Public Sub color_chart()
Dim cIt As Integer
Dim sIt As Integer
Dim pIt As Integer
Dim seriesArray() As Variant
For cIt = 1 To ActiveWorkbook.Sheets("OVERALL").ChartObjects.Count
For sIt = 1 To 2
seriesArray = ActiveWorkbook.Sheets("OVERALL").ChartObjects(cIt).Chart.SeriesCollection(sIt).Values
With ActiveWorkbook.Sheets("OVERALL").ChartObjects(cIt). _
Chart.SeriesCollection(sIt).DataLabels.Font
.Name = "Arial"
.FontStyle = "Italic"
.Size = 8
'.Bold = True
.ColorIndex = 3 ' rød
'.Strikethrough = False
'.Superscript = False
'.Subscript = False
'.OutlineFont = False
'.Shadow = False
'.Underline = xlUnderlineStyleNone
.Background = xlAutomatic
End With
For pIt = 1 To UBound(seriesArray)
Select Case Round(seriesArray(pIt), 1)
Case Is >= 5
ActiveWorkbook.Sheets("OVERALL").ChartObjects(cIt). _
Chart.SeriesCollection(sIt).Points(pIt).Interior.Color = RGB(0, 128, 0)
Case 3 To 5
ActiveWorkbook.Sheets("OVERALL").ChartObjects(cIt). _
Chart.SeriesCollection(sIt).Points(pIt).Interior.Color = RGB(204, 255, 204)
Case Else
ActiveWorkbook.Sheets("OVERALL").ChartObjects(cIt). _
Chart.SeriesCollection(sIt).Points(pIt).Interior.Color = RGB(255, 255, 153)
End Select
Next pIt
Next sIt
Next cIt
End Sub