VBA情节盒和胡须图表
我正在试图自动绘制一个盒子和胡须图表。 下面的代码编译并运行,但错误栏不显示在图表中。
Dim ws As Worksheet Dim datarange As Range Dim chtChart As Chart Dim objChrt As ChartObject Set ws = Sheets("sheet1") Set datarange = ws.Range("F8:G10") Set chtChart = Charts.add With chtChart chtChart.ChartType = xlColumnStacked chtChart.SetSourceData Source:=datarange, PlotBy:=xlColumns With .Axes(xlCategory, xlPrimary) .CategoryNames = ws.Range("A2:A13") .TickLabels.Font.Bold = True End With .SeriesCollection(1).Format.Fill.Visible = msoFalse .SeriesCollection(2).Format.Fill.Visible = msoTrue Dim Sec1 As Series Set Sec1 = .SeriesCollection.NewSeries .SeriesCollection(3).HasErrorBars = True .SeriesCollection(3).ErrorBars.EndStyle = xlCap .SeriesCollection(3).ErrorBars.Format.Line.Visible = msoTrue .SeriesCollection(3).ErrorBars.Format.Line.ForeColor.RGB = RGB(0, 0, 0) .SeriesCollection(3).ErrorBars.Format.Line.Transparency = 0 .SeriesCollection(3).ErrorBars.Format.Line.Weight = 1.5 .SeriesCollection(3).ErrorBar Direction:=xlX, Include:=xlErrorBarIncludeBoth, Type:=xlErrorBarTypeCustom, Amount:="=CHART!F12:G12", MinusValues:="=CHART!F12:G12"
解决了。
.SeriesCollection(3).values= <data range for whisker length>
绘制晶须所需的数据值重要说明:这会覆盖系列收集值(在此情况下是系列收集(3)),可以在绘制须晶