+ Reply to Thread
Results 1 to 4 of 4

Call slope function from VBA

  1. #1
    Registered User
    Join Date
    06-04-2004
    Posts
    9

    Question Call slope function from VBA

    Dear Friends,

    I have to local ranges, xL and yL that I have assigned some values to each of them. Now, I want to call the slope and the intercept functions to calculate their regression statistics.

    I expected to do something like:

    slopeL = "=SLOPE(yL,xL)"

    Any ideas?

    G.

  2. #2
    Forum Contributor
    Join Date
    06-10-2004
    Location
    India
    Posts
    1,066
    Suppose the X is in A1:A10, and Y is in B1:B10, then use


    set xL = Range("A10:A10")
    set yL = Range("B10:B10")

    slopeL = Application.WorksheetFunction.Slope(yL, xL)


    - Mangesh

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello G.,

    The worksheet formulae are SLOPE and INTERCEPT.

    Using the Excel Formula Bar :

    =SLOPE(Known_Ys, Known_Xs)
    =INTERCEPT(Known_Ys, Known_Xs)

    Using VBA:

    Worksheets("Sheet1").WorksheetFunction.Slope(Known_Ys, Known_Xs)
    Worksheets("Sheet1").WorksheetFunction.Intercept(Known_Ys, Known_Xs)
    _________________________________________________________________

    This should get you going in the right direction,
    Leith Ross

  4. #4
    Registered User
    Join Date
    06-04-2004
    Posts
    9

    Wink Thank you

    Thank you,

    problem solved.

    G.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1