habe aus dem link excelbeispiele.de folgenden Code um die Farbe von Diagrammbalken über Grenzwerte zu definieren. Es handelt sich in dem Beispiel aber um ein Punkte Diagramm und ich wollte meine Tabelle über ein Balkendiagramm darstellen. Wie muss ich den Code hiefür verändern?
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim varArray As Variant, objSeries As Series, intIndex As Integer
Application.ScreenUpdating = False
If Target.Cells = "" Then
Exit Sub
Else
ActiveSheet.ChartObjects("Diagramm 2").Activate 'Name anpassen!!
Set objSeries = ActiveChart.SeriesCollection(1)
varArray = objSeries.Values
For intIndex = LBound(varArray) To UBound(varArray)
With objSeries.Points(intIndex)
'.MarkerBackgroundColorIndex = 2
If varArray(intIndex) = 1 Then .MarkerBackgroundColorIndex = 3
If varArray(intIndex) = 1 Then .MarkerForegroundColorIndex = 3
If varArray(intIndex) = 2 Then .MarkerBackgroundColorIndex = 4
If varArray(intIndex) = 2 Then .MarkerForegroundColorIndex = 4
If varArray(intIndex) = 3 Then .MarkerBackgroundColorIndex = 5
If varArray(intIndex) = 3 Then .MarkerForegroundColorIndex = 5
If varArray(intIndex) = 4 Then .MarkerBackgroundColorIndex = 6
If varArray(intIndex) = 4 Then .MarkerForegroundColorIndex = 6
If varArray(intIndex) = 5 Then .MarkerBackgroundColorIndex = 7
If varArray(intIndex) = 5 Then .MarkerForegroundColorIndex = 7
If varArray(intIndex) = 6 Then .MarkerBackgroundColorIndex = 8
If varArray(intIndex) = 6 Then .MarkerForegroundColorIndex = 8
End With
Next
Target.Activate
End If
Application.ScreenUpdating = True
End Sub
Danke für eure Hilfe!
vg
Philipp