Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 274
  • Last Modified:

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
0
kosenrufu
Asked:
kosenrufu
  • 2
1 Solution
 
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

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now