Results 1 to 7 of 7

LINEST with an autopopulating array within VBA

Threaded View

  1. #1
    Registered User
    Join Date
    03-22-2013
    Location
    reading, england
    MS-Off Ver
    Excel 2010
    Posts
    4

    LINEST with an autopopulating array within VBA

    Hi all,

    essentially I am trying to populate an array within a VBA code and then regress the line using the LINEST function

    Based on something I saw in one of these forums I tried the following


      Sub LinestTest()
    Dim Y As Variant, X As Variant
     
    ReDim Y(1 To 3, 1 To 1)
    ReDim X(1 To 3, 1 To 1)
     
    
    
    q = 4
    For i = 1 To 3
        Y(i, 1) = q
        q = q + 1
    Next
    
    
    Z = 4
    For i = 1 To 3
        X(i, 1) = Z
       Z = Z + 1
    Next
    
    
     
    C1 = Application.WorksheetFunction.Index(Application.WorksheetFunction.LinEst(Y, X ^ [1,2,3,4,5,6]), 1)
     
    
     
    End Sub

    however I get a mismatch error can anyone explain what is wrong with the code and what I need to do to extract the regressed coefficients (1-7)
    Last edited by grimster85; 03-22-2013 at 05:49 PM.

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