I searched this forum and found this code to run many simple regressions at once (3600 of them) and send the output for all of them to a single worksheet. It runs a regression for the data in column 3 against the data column 65, then column 3 against column 66, etc., then column 4 against column 65, then column 4 against 66, etc., and so on. It works beautifully, but what I would like to do is run a regression for the data in column 3 against the data in column 65, then 4 against 66, then 5 against 67, and so on for a total of 60 regressions.
Unfortunately, I can't seem to correctly modify the code in order to make that happen. Can anyone help me? Thanks in advance!
Sub aaa()
Dim DataSH As Worksheet, OutSH As Worksheet
Dim rngY As Range, rngX As Range, rngOut As Range
Set DataSH = Sheets("Data 2")
Set OutSH = Sheets("Sheet2")
OutSH.Cells.ClearContents
OutSH.Activate
For i = 3 To 63
For j = 65 To 125
Application.StatusBar = i & ":" & j
With DataSH
Set rngY = .Range(.Cells(5, i), .Cells(5, i).End(xlDown))
Set rngX = .Range(.Cells(5, j), .Cells(5, j).End(xlDown))
End With
Cells(Rows.Count, "A").End(xlUp).Offset(2, 0).Value = DataSH.Cells(5, i) & " : " & DataSH.Cells(5, j)
Set rngOut = Cells(Rows.Count, "A").End(xlUp).Offset(2, 0)
Application.Run "ATPVBAEN.XLAM!Regress", rngY, rngX, False, True, , rngOut, False _
, False, False, False, , False
Next j
Next i
Application.StatusBar = False
End Sub
Bookmarks