Sub MakeChart()
Dim x(20) As Variant
Dim y(20) As Variant
Dim i As Long
For i = 0 To 20
x(i) = i * 2
y(i) = 2 * Sin(i / 5)
Next
Charts.Add
With ActiveChart
.ChartType = xlLineMarkers
.HasTitle = True
.ChartTitle.Text = "Plot from Array"
With .Axes(xlCategory, xlPrimary)
.HasTitle = True
.AxisTitle.Characters.Text = "X"
End With
.SeriesCollection.NewSeries
With .SeriesCollection(1)
.XValues = x
.Values = y
.Trendlines.Add
.Trendlines(1).DisplayEquation = True
.Name = "Y"
End With
End With
End Sub
That draws a curve then fits a trend line to it.
If you replace the loop at the start of the code that populates the arrays with your code to get the data it should do what you want.