I'm trying to create a range from non-contiguous ranges and utilize Linest function.
I have a worksheet attached.
In this worksheet there is data in cells A2:K92 and again from O2:Q92
The data in Column A matches the data in column O
The data in Column C matches the data in column P
The data in Column K matches the data in column Q
There is also an array function in the worksheet from S2:U6
={linest(Q2:Q92,O2:P92,0,true)}
There is a macro in the worksheet
Sub Macro()
Dim Yrng As Range
Dim Xrng As Range
Dim v
Set Yrng = Range("Q2:Q92")
Set Xrng = Range("P2:P92","O2:O92")
v = Application.WorksheetFunction.LinEst(Yrng,Xrng,0,True)
Range("S8:U12") = v
End Sub
When I run the macro I get the exact same results as the Linest.
What I need to do is create it out of the non-contiguous ranges
But when I try:
Sub Macro()
Dim Yrng As Range
Dim Xrng As Range
Dim v
Set Yrng = Range("K2:K92")
Set Xrng = Range("A2:A92","C2:C92")
v = Application.WorksheetFunction.Linest(Yrng,Xrng,0,true)
Range("S8:U12") = v
End Sub
The values I get back are not the same - even though the inputs are the same (as shown by the data in column M
What gives?
Bookmarks