各行に新しいシリーズが最適です。 (各カットのための1行を追加すること)
'add a line series with line but no markers
Sub AddLineSeries(cht As ChartObject, sName As String, xvals, _
yvals, SeriesColor As Long)
Dim s As Series
Set s = cht.Chart.SeriesCollection.NewSeries
With s
.Name = sName
.Values = yvals
.XValues = xvals
.MarkerBackgroundColor = xlNone
.MarkerForegroundColor = SeriesColor
.MarkerStyle = xlMarkerStyleNone
With .Border
.Weight = xlThin
.Color = SeriesColor
End With
End With
End Sub
使用法:
'cht is the chart object
'minX/maxX are x-axis values you want to plot the line for
'qcMin/Max are the y-axis values for your lower/upper cut-offs
'Array() just creates an array of values to pass to the chart for plotting, since
' we're not using values from a worksheet for this series
AddLineSeries cht, "QC Min", Array(minX, maxX), Array(qcMin, qcMin), _
RGB(255, 0, 0)
AddLineSeries cht, "QC Max", Array(maxX, maxX), Array(qcMax, qcMax), _
RGB(255, 0, 0)
私は行ごとに別々のデータ系列を使用します。あなただけの行を作成するために、2つの点を必要とします。 –