B = Y Intercept

  • Thread starter Thread starter Alex A
  • Start date Start date
A

Alex A

I used the two functions slope and Intercept but for some
reason the intercept is coming out wrong. Here is the
code...
Slope = Application.WorksheetFunction.Slope(Range
("e25:e28"), Range("c25:c28"))

Intercept = Application.WorksheetFunction.Intercept(Range
("e25:e28"), Range("c25:c28"))

The label on the graph shows y = 14484x + 562698 and so
my code should produce the same results but it doesn't...

My slope is 14483.664 (good)
My intercept is -28390146.1562596 (bad) should be 562698

Thoughts?: The 0nly thing I can think of is that the
values in the "c" range are 2000,2001,2002,2003 and
somehow my answer is the Y intercept at the year 0????

Or maybe the datatypes are causing a bad answer..one cell
range has the Excel 'Number' datatype and the other cell
range is the Excel 'Currency' datatype

Please advise
Alex.
 
My guess is that your graph is a "Line" chart instead of an "XY
(Scatter)" chart. If so, then the VBA intercept is correct because the
graph equation is based on the assumption that the X data is 1,2,3,4
(2000,2001,2002,2003 are just x labels, not x values in a "Line" chart).

Jerry
 
Back
Top