Ich versuche, in einem Säulen-Diagramm columnClustered und columnStacked zu kombinieren. Das scheint nicht zu gehen.
Leider schaffe ich es nicht, das Duagramm einzufügen.
Sub macro3()
Dim col_chart As chart
Dim yy(3, 5) As Single
Dim y(3) As Single
Dim year(3) As Single
Dim x(5) As String
x(1) = "A"
x(2) = "b"
x(3) = "c"
x(4) = "d"
x(5) = "e"
year(1) = 23
year(2) = 24
year(3) = 25
yy(1, 1) = 1
yy(2, 1) = 2
yy(3, 1) = 3
yy(1, 2) = 15
yy(2, 2) = 25
yy(3, 2) = 35
yy(1, 3) = 10
yy(2, 3) = 20
yy(3, 3) = 30
yy(1, 4) = 6
yy(2, 4) = 7
yy(3, 4) = 8
yy(1, 5) = 40
yy(2, 5) = 30
yy(3, 5) = 20
Set col_chart = ThisWorkbook.Worksheets("Tabelle1").Shapes.AddChart(Left:=350, Width:=500, Top:=50, Height:=200).chart
With col_chart
.Axes(xlValue).TickLabels.NumberFormat = "#.##0 €"
.HasLegend = True
For i = 1 To 5
For j = 1 To UBound(yy, 1)
y(j) = yy(j, i)
Next j
.SeriesCollection.NewSeries
If i = 1 Then
.FullSeriesCollection(i).ChartType = xlColumnStacked
ElseIf i > 2 Then
.FullSeriesCollection(i).ChartType = xlColumnClustered
End If
.FullSeriesCollection(i).values = y
.FullSeriesCollection(i).XValues = year
.FullSeriesCollection(i).name = x(i)
Next i
End With
End Sub
Wenn ich dagegen:
If i = 1 Then
.FullSeriesCollection(i).ChartType = xlColumnStacked
ElseIf i > 2 Then
.FullSeriesCollection(i).ChartType = xlLine
End If
bekomme ich zwei gestapelte Säulne und drei Lines.
(was ich auch nicht verstehe: warum werden ACHT Datenreihen gelistet und VIER Elemente auf der x-Achse)
|