我已经编写了在两列中随机创建1到5之间的500个数字的代码。 我希望这两列之间的相关性大于0.35,但这永远不会发生。 该代码应如何更正?
Sub rand()
Dim p, x, y As Integer
Dim Rang As Range
Do
For p = 1 To 2
For y = 2 To 500
If p <= 2 And y <= 500 Then
Set Rang = Cells(y, p)
Rang = Application.WorksheetFunction.RandBetween(1, 5)
End If
Next
Next
Correl = WorksheetFunction.Correl(Range(Cells(2, 1), Cells(500, 1)), Range(Cells(2, 2), Cells(500, 2)))
Loop Until Correl > 0.3
End Sub