Hi,

I'm trying to assign variable ranges as input to Linest, using 2 independent variables. The following code fails. I'm sure this is something simple, but Im stumped.

Sub blind()
Dim J As Integer
Dim x As Range, y As Range

Set ws1 = Worksheets("sheet1")
Set ws2 = Worksheets("sheet2")
Set ws3 = Worksheets("sheet4")

ws1.Activate
J = 4  'I want this to be a variable, but setting it to 4 as a test
Set y = Range(Cells(2, 2), Cells(J, 2))
Set x = Range(Cells(2, 3), Cells(J, 4))

ws3.Activate
Range("g2: i6") = Application.LinEst(y, x, True, True)

End Sub