calculation slope vba

Public Schedule Face-to-Face & Virtual Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft Access VBA Training and help » Calculation of slope in VBA

Calculation of slope in VBA

resolvedResolved · Urgent Priority · Version 2007

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

Sat 30 Jul 2011: Automatically marked as resolved.

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


Server loaded in 0.07 secs.