dies ist mein erste Frage und auch erster Post.
Meine VBA Kenntnisse sind ok, aber noch lange nicht gut.
Bisher habe ich mit dem Makro Rekorder aufgenommen und ggf. optimiert oder mit Hilfe des Internets angepasst.
Nachdem die Recherche Funktion mir hier nicht weiterhelfen konnte wollte ich euch fragen, ob ihr eine Idee zu meinen Probemen habt.
Nun zu meinem Problem:
Ich möchte mir per VBA ein Boxplot Diagramm erstellen lassen.
Dieses stellt aus einem Datensatz die Min, Max, Median, 1. und 3. Quartilwerte da.
Eigentlich habe ich mit der Diagrammerstellung keine Probleme, aber hier will es einfach nicht klappen..
Mein bisheriger Code funktioniert nur für einen einzigen Fall (angepasst vom Makrorekroder), aber sobald man diesen etwas algemeiner halten will funktioniert er schon nicht mehr und für den Median würde ich eigenltich eine Linie statt Punkt haben wollen...
Der Excel interne Diagrammtyp gefällt mir nicht sonderlich hier würde ich vorallem per VBA gerne die Füllfarbe gleich leer und den Rahmen schwarz setzen lassen.
Hier der Link zu meiner Datei mit den vollständigen Makros.
https://www.herber.de/bbs/user/120504.xlsm
Wenn jemand eine Idee/Ansatz hat, dann bitte einfach posten.
Außerdem wäre es nett, wenn jemand noch 1-2 Satz zu zB. "FullSeriesCollection" schreiben könnte. Die Hilfe war mir leider keine wirkliche Hilfe.
Viele Dank im Voraus und Grüße
Carlos
Sub Boxplot()
Worksheets("Tabelle3").Activate
Range("A4").FormulaR1C1 = "Bezeichnung"
Range("A5").FormulaR1C1 = "a"
Range("B4").FormulaR1C1 = "Oberes Quantil"
Range("B5").FormulaR1C1 = "150"
Range("C4").FormulaR1C1 = "Maximum"
Range("C5").FormulaR1C1 = "200"
Range("D4").FormulaR1C1 = "Minimum"
Range("D5").FormulaR1C1 = "100"
Range("E4").FormulaR1C1 = "Unteres Quantil"
Range("E5").FormulaR1C1 = "117"
Range("F4").FormulaR1C1 = "Median"
Range("F5").FormulaR1C1 = "133"
With Range("A4:F5")
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
End With
ActiveSheet.Shapes.AddChart2(201, xlColumnClustered).Select
ActiveChart.SetSourceData Source:=Range("Tabelle3!$A$4:$F$5")
ActiveChart.PlotBy = xlColumns
ActiveChart.ChartType = xlColumnClustered
ActiveChart.FullSeriesCollection(1).ChartType = xlColumnClustered '3.Q
ActiveChart.FullSeriesCollection(1).AxisGroup = 1
ActiveChart.FullSeriesCollection(2).ChartType = xlColumnClustered 'max
ActiveChart.FullSeriesCollection(2).AxisGroup = 1
ActiveChart.FullSeriesCollection(3).ChartType = xlColumnClustered 'min
ActiveChart.FullSeriesCollection(3).AxisGroup = 1
ActiveChart.FullSeriesCollection(4).ChartType = xlLine '1.Q
ActiveChart.FullSeriesCollection(4).AxisGroup = 1
ActiveChart.FullSeriesCollection(5).ChartType = xlLine 'med
ActiveChart.FullSeriesCollection(5).AxisGroup = 1
ActiveChart.FullSeriesCollection(1).ChartType = xlLine
ActiveChart.FullSeriesCollection(2).ChartType = xlLine
ActiveChart.FullSeriesCollection(3).ChartType = xlLine
ActiveChart.FullSeriesCollection(5).ChartType = xlXYScatter
ActiveChart.Axes(xlCategory, xlSecondary).Delete
ActiveChart.Axes(xlValue, xlSecondary).Delete
ActiveChart.FullSeriesCollection(5).Select
ActiveChart.SetElement (msoElementErrorBarStandardDeviation)
ActiveChart.Axes(xlValue).Select
ActiveChart.Axes(xlValue).MajorGridlines.Delete
ActiveChart.Axes(xlValue).Select
ActiveChart.Axes(xlValue).HasMajorGridlines = True
ActiveChart.PlotArea.Select
Selection.Format.Fill.Visible = msoFalse
ActiveChart.Axes(xlValue).MajorGridlines.Select
ActiveChart.ChartArea.Select
Selection.Format.Line.Visible = msoFalse
With ActiveChart.Axes(xlValue).Format.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 255, 255)
.Solid
End With
ActiveChart.Axes(xlValue).MajorTickMark = xlInside
With ActiveChart.PlotArea.Format.Line
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = -0.349999994
End With
ActiveChart.Axes(xlValue).MajorTickMark = xlOutside
ActiveChart.FullSeriesCollection(2).Select
ActiveChart.SetElement (msoElementLineHiLoLine)
ActiveChart.Axes(xlValue).MajorGridlines.Select
With ActiveChart.ChartGroups(1)
.HasUpDownBars = True
End With
With ActiveChart.ChartGroups(1).DownBars.Format.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 255, 255)
.Solid
End With
With ActiveChart.ChartGroups(1).HiLoLines.Format.Line
.Visible = msoTrue
.Weight = 0.5
End With
With ActiveChart.ChartGroups(1).HiLoLines.Format.Line
.Visible = msoTrue
.Weight = 0.5
End With
ActiveChart.ChartGroups(1).DownBars.Select
With Selection.Format.Line
.Visible = msoTrue
.Weight = 0.5
End With
ActiveChart.Axes(xlCategory).Select
ActiveChart.Axes(xlCategory).AxisBetweenCategories = False
ActiveChart.Axes(xlCategory).AxisBetweenCategories = True
ActiveChart.Axes(xlCategory).CrossesAt = 1
ActiveChart.Axes(xlCategory).Crosses = xlAutomatic
ActiveChart.Axes(xlCategory).TickLabelSpacing = 1
ActiveChart.Axes(xlCategory).TickLabelSpacingIsAuto = True
' ActiveChart.PlotArea.Select
' ActiveChart.ChartArea.Select
' ActiveChart.Axes(xlCategory).Select
ActiveChart.Axes(xlValue).MajorGridlines.Delete
With ActiveChart.Axes(xlValue).Format.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(166, 166, 166)
End With
ActiveChart.Axes(xlValue).MajorTickMark = xlOutside
ActiveChart.PlotArea.Select
Selection.ClearFormats
With ActiveChart.Axes(xlValue, xlPrimary) 'y-Achse
.MinimumScale = Range("D5")
.MaximumScale = Range("C5")
End With
End Sub