Pierre has attended:
Excel VBA Intro Intermediate course
Calculation of slope in VBA
Hi,
I tried to calculate a slope in VBA using this:
Sub DeactivationRates()
Dim xL As Range
Dim yL As Range
Dim intSlopeL As Integer
Set xL = Range("B14:B76")
Set yL = Range("C14:C76")
intSlopeL = Application.WorksheetFunction.Slope(yL, xL)
Sheets("Sheet1").Range("B1").Value = intSlopeL
End Sub
I always get the same value of 0.000. Can you help?
Regards,
Pierre
RE: Calculation of slope in VBA
Hi Pierre
Thanks for your question
The first thing that strikes me is that you have declared intslopeL as an integer. As the slope of a line is nearly always a decimal less than 1, this would mean the value will always b e returned to the nearest integer. Try using single as the variable type and see if that helps
Regards
Stephen