+ Reply to Thread
Results 1 to 3 of 3

VBA for correlation coefficient matrix

  1. #1
    Registered User
    Join Date
    12-10-2011
    Location
    KSA
    MS-Off Ver
    Excel 2010
    Posts
    5

    VBA for correlation coefficient matrix

    Hi,

    I have a VBA code for Correl function,

    The code is

    Function CorrMatrix(rng As Range) As Variant
    Dim i As Long
    Dim j As Long
    Dim numCols As Long
    numCols = rng.Columns.Count
    numRows = rng.Rows.Count
    Dim matrix() As Double
    ReDim matrix(numCols - 1, numCols - 1)

    For i = 1 To numCols
    For j = 1 To numCols
    matrix(i - 1, j - 1) = Application.WorksheetFunction.Correl(rng.Columns(i), rng.Columns(j))
    Next j
    Next i
    CorrMatrix = matrix
    End Function


    The problem is this code works for just 59 colomns, I have almost 150 colmns, when I apply this code I get #Value! error.
    Any idea how can I solve this ?

  2. #2
    Forum Contributor
    Join Date
    04-11-2011
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    325

    Re: VBA for correlation coefficient matrix

    What line is the error in?

    Can you post a workbook?

  3. #3
    Registered User
    Join Date
    12-10-2011
    Location
    KSA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: VBA for correlation coefficient matrix

    I have solved the issue already, Thank you for your reply anyway.
    Last edited by Mob; 12-22-2011 at 01:46 PM.

+ 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