AW: Excel VBA
29.01.2021 10:30:57
Gert
Danke für die schnelle Reaktion. Hier der Link auf ein Diagramm:
Hier die programmierte Aufbereitung des Diagramms. Die Parameter werden über eine Userformn abgefragt
Public Sub NeuesChart()
Dim Bereich As String
Dim cht As Chart
ThisWorkbook.Charts.Add Before:=Worksheets("Gesamtbilanz")
Bereich = "H" & ChartVon & ":I" & ChartBis + 1
ActiveChart.SetSourceData Worksheets("Gesamtbilanz").Range(Bereich)
ActiveChart.Name = ChartNeu
Set cht = ThisWorkbook.Charts(ChartNeu)
With cht
.ChartType = xlLine
.HasTitle = True
.ChartTitle.Text = "Wertobjekte und Gesamtbilanz"
.ChartTitle.Font.Size = 16
.ChartTitle.Font.FontStyle = "Bold"
.ChartTitle.Font.Color = RGB(255, 0, 0)
.HasLegend = True
.Legend.IncludeInLayout = False
.Legend.Position = xlLegendPositionBottom
.Legend.IncludeInLayout = True
'Trendlinie für Wertobjekte erstellen und konfigurieren
.FullSeriesCollection(1).Name = "Wertobjekte"
.FullSeriesCollection(1).Trendlines.Add
.FullSeriesCollection(1).Trendlines(1).Type = xlPolynomial
.FullSeriesCollection(1).Trendlines(1).Select
With Selection.Format.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 112, 192)
.Transparency = 0
End With
'Linienstärke für Fieberkuve Wertobjekte
ActiveChart.FullSeriesCollection(1).Select
With Selection.Format.Line
.Visible = msoTrue
.Weight = 4
End With
'Breite und Linienstil für Trendline Wertobjekte
.FullSeriesCollection(1).Trendlines(1).Select
With Selection.Format.Line
.Visible = msoTrue
.Weight = 5
End With
With Selection.Format.Line
.Visible = msoTrue
.DashStyle = msoLineSysDot
End With
'Trendlinie für Gesamtbilanz erstellen und konfigurieren
.FullSeriesCollection(2).Name = "Bilanz"
.FullSeriesCollection(2).Trendlines.Add
.FullSeriesCollection(2).Trendlines(1).Type = xlPolynomial
.FullSeriesCollection(2).Trendlines(1).Select
With Selection.Format.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(192, 0, 0)
.Transparency = 0
End With
'Linienstärke für Fieberkuve Bilanz
ActiveChart.FullSeriesCollection(2).Select
With Selection.Format.Line
.Visible = msoTrue
.Weight = 4
End With
'Breite und Linienstil für Trendline Gesamtbilanz
.FullSeriesCollection(2).Trendlines(1).Select
With Selection.Format.Line
.Visible = msoTrue
.Weight = 5
End With
With Selection.Format.Line
.Visible = msoTrue
.DashStyle = msoLineSysDot
End With
'Plot-Fläche ausfüllen
.ChartArea.Select
.PlotArea.Select
With Selection.Format.Fill
.Visible = msoTrue
.PresetTextured msoTextureParchment
.TextureTile = msoTrue
.TextureOffsetX = 0
.TextureOffsetY = 0
.TextureHorizontalScale = 1
.TextureVerticalScale = 1
.TextureAlignment = msoTextureTopLeft
End With
'Achsen anzeigen
.HasAxis(xlCategory, xlPrimary) = True 'X-Achse
.HasAxis(xlValue, xlPrimary) = True 'Y-Achse
With .Axes(xlCategory) 'Bringt nicht die erhoffte Wirkung
.MajorUnit = 100
.MinorUnit = 20
End With
End With
End Sub