# help please covariance

1. ## help please covariance

Hi people,
I have a spreadsheet with M-1 rows and N colomns. I want to calcolate the covariance matrix of the spreadsheet and i would like like output an other spreadsheet. I tried to do my self, but no so much result. here my code, but there is a listake
Sub cov()
Dim LR As Long, i As Long, j As Long, LC As Integer
Dim ws1 As Worksheet, ws2 As Worksheet
Application.ScreenUpdating = False
Set ws1 = Sheets("DIFF")
Set ws2 = Worksheets.Add
With ws1
LR = .Cells(Rows.Count, 1).End(xlUp).Row
LC = .Cells(1, Columns.Count).End(xlToLeft).Column
For i = 1 To LR - 1
ws2.Cells(i, i) = Application.Covar(Cells(i, i), Cells(i, i))
For j = i + 1 To LC
covval = Application.Covar(Cells(i, i).Value, Cells(i, j).Value)
ws2.Cells(i, j) = covval
ws2.Cells(j, i) = covval

Next j
Next i
End With
Application.ScreenUpdating = True
End Sub

Please help me. The mistake has to be in this line ws2.Cells(i, i) = Application.Covar(Cells(i, i), Cells(i, i))
can I use excel function for generic cells?
Also I have to diagonilize the matrix and to find the autovalue...so much work head till tomorrow
Also I find some problem in interface cells and spreadsheet. Somebody know some good tutorial?
cheers
Alice

Alice

2. ## Re: help please covariance

Welcome to the forum.

Please take a few minutes to read the forum rules, and then edit your post to add code tags.

Thanks.

3. ## Re: help please covariance

Hi,

You have broken two of the forum rules please read them and amend your question - thanks

To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

##### Users Browsing this Thread

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

#### 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