+ Reply to Thread
Results 1 to 4 of 4

Why does my trendline equation change?

Hybrid View

  1. #1
    Registered User
    Join Date
    06-21-2014
    Location
    Wyoming, United States, Earth, Milky Way Galaxy
    MS-Off Ver
    2007
    Posts
    4

    Why does my trendline equation change?

    I've got a somewhat complicated XY Scatter chart. When I view one data series, the linear trendline equation is 'y=-30.179x+5427.5'. When I add a 2nd data series, it changes to 'y=95.117+331.52'. The 2nd trend line is correct.

    Why would this happen? The data set for the 1st series has not. When I add a 3rd, 4th, ... 7th series, they too are messed up.

    The data subset is generated by a VBA search macro. I have confirmed the data is not different. Anyone have any clues here? I have plotted the data on the scatter chart, then manually added the trend lines, with the same results.

    Thanks for any help.
    Last edited by AngryRat77; 11-29-2014 at 08:26 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Why does my trendline equation change?

    Welcome to the forum.

    Please post workbooks, not pictures.

    Thanks.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    06-21-2014
    Location
    Wyoming, United States, Earth, Milky Way Galaxy
    MS-Off Ver
    2007
    Posts
    4

    Re: Why does my trendline equation change?

    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
    Last edited by AngryRat77; 11-29-2014 at 09:17 PM.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Why does my trendline equation change?

    There's nothing I can do with your code. Good luck.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 11-03-2014, 08:04 PM
  2. Replies: 3
    Last Post: 03-06-2011, 01:38 PM
  3. Replies: 1
    Last Post: 04-23-2009, 08:23 PM
  4. Trendline equation
    By safdarhassan in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 09-11-2007, 08:51 AM
  5. Trendline Equation- value of x?
    By bastien86 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-07-2006, 10:25 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1