Posting the workbook won't work, it's 2.8 megs, plus there is confidential data contained there in.
Here is the code I use to generate the plot data and the trend lines. There is a routine above this code that searches about 200 columns of various depth looking for matches entered in a userform. The x and y data are stored in 2 strings, separated by commas. I have stepped through the code, and watched the chart as it's being generated. After the first series is created, the trend line is correct. After the 2nd series, the trend line changes to an altered equation. I have tried commenting out code to find out what is going on, but it has not yeilded anything.
For iLooper = 0 To lbDate.ListCount - 1
Application.StatusBar = " Generating Chart " & Int(((iLooper + 1) / (lbDate.ListCount)) * 100) & "% Complete"
With ActiveChart.SeriesCollection.NewSeries
If Not chkTrend Or lbDate.ListCount = 1 Then .Name = "=" + Chr(34) + lbDate.List(iLooper) + " Data" + Chr(34)
.ChartType = xlXYScatter
.Values = "={" + ArrAxisDataY(iLooper) + "}"
.XValues = "={" + ArrAxisDataX(iLooper) + "}"
If Not chkTrend Then
.MarkerSize = 3
Else
.MarkerSize = 2
End If
.MarkerStyle = 8
End With
If chkTrend Then
If lbDate.ListCount > 1 Then
For iCount = 1 To ActiveChart.SeriesCollection(iLooper + 1).Points.Count
With ActiveChart.SeriesCollection(iLooper + 1).Points(iCount)
.Format.Fill.Solid
.MarkerBackgroundColor = rgbColor(iLooper)
.MarkerForegroundColor = rgbColor(iLooper)
End With
Next iCount
End If
With ActiveChart.SeriesCollection(iLooper + 1).Trendlines.Add
.Type = xlLinear
.Name = "=" + Chr(34) + lbDate.List(iLooper) + " Trends" + Chr(34)
.Border.LineStyle = xlContinuous
.Border.Weight = xlThick
.Border.Color = rgbColor(iLooper)
End With
End If
Next iLooper
Bookmarks