Новая серия для каждой линии - лучший подход.
'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)