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

Posted on 2011-04-27
Last Modified: 2012-05-11
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)

    Set xlApp = Nothing

Question by:kosenrufu
    LVL 39

    Accepted Solution

    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
        Set xlApp = Nothing
    LVL 39

    Expert Comment

    X(3) = 16

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Suggested Solutions

    This article is a continuation or rather an extension from Cascading Combos ( and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
    I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
    Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
    With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now