Hallo liebe Leute,
ich habe den folgenden Code:
Sub Farben_Diagramm()
Dim chtDiagramm As Chart
Dim i As Integer, j As Integer, intColor As Integer, intSeries As Integer
Dim strName As String, strChart As String, strBlatt As String
strBlatt = “Versuch”
strChart = “chartPersonal”
Set chtDiagramm = Sheets(strBlatt).ChartObjects(strChart).Chart
intSeries = chtDiagramm.SeriesCollection.Count
chtDiagramm.SetElement (msoElementDataLabelNone)
chtDiagramm.SetElement (msoElementDataLabelCenter)
For i = 1 To intSeries
strName = chtDiagramm.SeriesCollection(i).Name
For j = 2 To Range(“rng_Orte”).Value + 1
If Sheets(“Versuch”).Cells(j, 9).Value = strName Then
intColor = Sheets(“Versuch”).Cells(j, 14).Value
With chtDiagramm.SeriesCollection(strName)
.Format.Fill.Visible = msoTrue
.Format.Fill.ForeColor.RGB = RGB(Sheets(“Versuch”).Cells(j, 11).Value, _
Sheets(“Versuch”).Cells(j, 12).Value, Sheets(“Versuch”).Cells(j, 13).Value)
With .DataLabels.Format.TextFrame2.TextRange.Font.Fill
.ForeColor.RGB = RGB(intColor, intColor, intColor)
.Solid
End With
.DataLabels.Format.TextFrame2.TextRange.Font.Bold = msoTrue
End With
End If
Next j
Next i
Exit Sub
Leider tritt in der Zeile Set chtDiagramm = Sheets(strBlatt).ChartObjects(strChart).Chart
der Fehler Index außerhalb des gültigen Bereichs auf. Die Namen sind identisch. Was kann ich tun?
Liebe Grüße!
|