Last active
August 12, 2020 02:20
-
-
Save yuyueugene84/96b37b8605d3ea6de09708ff14ef1b3e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub CalculateCorr4() | |
Dim corrSheet As Worksheet | |
Set corrSheet = Worksheets("相關性分析") | |
Dim portSheet As Worksheet | |
Set portSheet = Worksheets("投資組合報酬分析") | |
Dim corr As Double | |
Dim i As Integer | |
Dim j as Integer | |
For j = 2 To 13 | |
For i = 2 To 13 | |
corr = Application.WorksheetFunction.Correl( _ | |
portSheet.Range( _ | |
portSheet.Cells(2, j), _ | |
portSheet.Cells(95, j) _ | |
).Value, _ | |
portSheet.Range( _ | |
portSheet.Cells(2, i), _ | |
portSheet.Cells(95, i) _ | |
).Value _ | |
) | |
Debug.Print corr | |
corrSheet.Cells(i, j).Value = corr | |
Next i | |
Next j | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment