Habs hinbekommen, hier der finale Code:
'Source: https://thehosblog.com/2014/10/13/excel-diagrammfarben-per-vba-zuweisen/
Sub Farben_Diagramm()
Dim chtDiagramm As Chart
Dim i As Integer, j As Integer, intColor As Integer, intSeries As Integer, Color As Integer
Dim strName As String, strChart As String, strBlatt As String
Dim rng As Range
Dim colorValue As Variant
'On Error GoTo ErrorHandler
strBlatt = "Uebersicht"
strChart = "UebersichtDia"
Set chtDiagramm = Sheets(strBlatt).ChartObjects(strChart).Chart
intSeries = chtDiagramm.SeriesCollection.Count
For i = 1 To intSeries
strName = chtDiagramm.SeriesCollection(i).Name
For j = 2 To Range("RangePhase").Value + 1
If Sheets("Pers_Input").Cells(j, 1).Value = strName Then
'Textfarbe bestimmen: 'intColor = Sheets(„Pers_Input“).Cells(j, 14).Value
With chtDiagramm.SeriesCollection(strName)
.Format.Fill.Visible = msoTrue
colorValue = Sheets("Pers_Input").Cells(j, 4).DisplayFormat.Interior.Color
.Format.Fill.ForeColor.RGB = RGB((colorValue Mod 256), ((colorValue \ 256) Mod 256), (colorValue \ 65536))
End With
End If
Next j
Next i
' Exit Sub
'ErrorHandler:
' MsgBox „Ein Fehler ist aufgetreten“, vbInformation, „Fehler “ & Err.Number
End Sub
|