How to pass a record set to the Excel slope function in Access?

Hi Experts,

I have this type of data

WeekNo      SC_Dly_ProjAccurcy_Avg_Last_x_Wks
13      0.924868312317044
14      0.934322001485006
15      0.906667898893364
16      0.95072420264395

How can I programmatically use the Excel slope function within Access?

I have this code :
    Dim xlApp As Object

    Set xlApp = CreateObject("Excel.Application")

    'Use SLOPE() in an expression:
    'SomeVariable = xlApp.Slope(y, x)

    xlApp.Quit
    Set xlApp = Nothing


THANKS
kosenrufuAsked:
Who is Participating?
 
als315Commented:
You need array for this function:

Dim xlApp As Object
Dim X(4), Y(4) As Double, Sl As Double
X(0) = 13
X(1) = 14
X(2) = 15
X(3) = 15
Y(0) = 0.924868312317044
Y(1) = 0.934322001485006
Y(2) = 0.906667898893364
Y(3) = 0.95072420264395

    Set xlApp = CreateObject("Excel.Application")

    'Use SLOPE() in an expression:
    Sl = xlApp.Slope(Y, X)
    MsgBox Sl, vbOKOnly
    xlApp.Quit
    Set xlApp = Nothing
0
 
als315Commented:
X(3) = 16
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.