Hello,
I am trying to run the following regression with a 'for' loop.
I get an error message that the reference is wrong. When I refer to other sheets i normally use the 'with' function, but in this case this is not possible. Can somebody help me to use the reference in the regression correctly?
Thanks
Timi
I am trying to run the following regression with a 'for' loop.
Code:
Sub Betas()
For i = 1 To 10
Application.Run "ATPVBAEN.XLAM!Regress", Sheets("Rt").Range(.Cells(2, i + 1), .Cells(246, i + 1)), _
Sheets("Rm").Range(.Cells(2, i + 1), .Cells(246, i + 1)), False, False, , Worksheets("Regressionen").Range("$A$1") _
, False, False, False, False, , False
Sheets("Regressionen").Select
Range("B18").Select 'copy Beta
Selection.Copy
With Sheets("Betas")
.Cells(2, i).Paste
End With
Next i
End Sub
I get an error message that the reference is wrong. When I refer to other sheets i normally use the 'with' function, but in this case this is not possible. Can somebody help me to use the reference in the regression correctly?
Thanks
Timi