Unable to get the Pearson Property of the worksheetfunction class

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,674
This is not what's causing your problem (ATM, anyway), but you are calculating e and f separately, and they must be the same; Correl (and Pearson) require equal-size arrays.
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,674
And the assignment of e and f needs to be in that With block, for the same reason as before.
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,674
And, unless your heart is set on VBA, this would be easy to do with formulas.
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,674
A​
B​
C​
D​
E​
F​
G​
H​
I​
J​
K​
1​
Data 1
Data 2
Data 3
Data 4
Data 1
Data 2
Data 3
Data 4
2​
70​
77​
79​
88​
Data 1
1​
-0.19294​
0.445674​
0.238539​
G2: =CORREL(A$2:A$21, INDEX($A$2:$D$21, 0, ROWS($G$1:G1)))
3​
54​
48​
18​
40​
Data 2
-0.19294​
1​
0.115421​
0.273441​
4​
90​
95​
99​
74​
Data 3
0.445674​
0.115421​
1​
0.312972​
5​
6​
79​
54​
37​
Data 4
0.238539​
0.273441​
0.312972​
1​
6​
100​
15​
80​
47​
7​
86​
42​
91​
60​
8​
57​
84​
97​
90​
9​
5​
39​
21​
92​
10​
1​
45​
51​
5​
11​
90​
24​
68​
86​
12​
25​
96​
82​
65​
13​
14​
74​
20​
33​
14​
1​
77​
40​
19​
15​
91​
59​
10​
18​
16​
69​
31​
91​
16​
17​
1​
34​
7​
53​
18​
13​
57​
85​
55​
19​
59​
30​
52​
67​
20​
61​
98​
81​
96​
21​
60​
1​
88​
30​
 

SBF12345

Well-known Member
Joined
Jul 26, 2014
Messages
614
When I watch the code and step through it with F8 the variable "a" reads "expression not defined in context" in the value area...further over in the context area it reads VBAProject.

This is different from the other variable "b" which is very similar and if functioning accordingly. The primary difference between the two is the "context". "b" reads "VBAProject.Module84.CMatrixUpdate"

How can I change the context?
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,674
Code:
Sub CMatrixUpdate()
  Dim rInp          As Range
  Dim rOut          As Range
  Dim sArg1         As String
  Dim sArg2         As String
  Dim sArg3         As String

  Set rInp = Workbooks("LOGREG_INPUT.xls").Worksheets("Paper1").Range("A2")
  Set rInp = Range(rInp, rInp.End(xlDown).End(xlToRight))

  Application.Goto rInp
  Stop  ' does that look correct?

  With rInp.Columns
    Set rOut = Workbooks("Matrix.xls").Worksheets("Paper2").Range("A2").Resize(.Count, .Count)
  End With

  Application.Goto rOut
  Stop  ' does that look correct?

  With rInp
    sArg1 = .Columns(1).Address(RowAbsolute:=True, ColumnAbsolute:=False, External:=True)
    sArg2 = .Address(RowAbsolute:=True, ColumnAbsolute:=True, External:=True)
    sArg3 = rOut.Cells(1).Address(RowAbsolute:=True, ColumnAbsolute:=True, External:=False) & ":" & _
            rOut.Cells(1).Address(False, False)
    rOut.Formula = "=CORREL(" & sArg1 & ", INDEX(" & sArg2 & ", 0, ROWS(" & sArg3 & ")))"
    ' rOut.Value = rOut.Value ' uncomment this line if you just want values
  End With
End Sub
 

SBF12345

Well-known Member
Joined
Jul 26, 2014
Messages
614
Thanks for the input...ill have to spend more time with the chunk above to see if I can get it running.
 

Forum statistics

Threads
1,077,649
Messages
5,335,473
Members
399,017
Latest member
npatel917

Some videos you may like

This Week's Hot Topics

Top