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

calculation slope vba

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

Calculation of slope in VBA

ResolvedVersion 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.

Access tip:

Convert A Form Into A Report

If there is a form that you want to to save as a report:

1. Open that form in Design View
2. Select File and Save As
3. In the Save As Dialog box Select Report

The system creates a report based on the form.

View all Access hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.1 secs.