Unable to get the Pearson Property of the worksheetfunction class

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,752
Office Version
2010
Platform
Windows
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.
 

Some videos you may like

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,752
Office Version
2010
Platform
Windows
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,752
Office Version
2010
Platform
Windows
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,752
Office Version
2010
Platform
Windows
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,752
Office Version
2010
Platform
Windows
Does post #14 essentially show what you're trying to do?
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,752
Office Version
2010
Platform
Windows
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,102,593
Messages
5,487,755
Members
407,610
Latest member
bellakim00

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...
Top