I have the following code that runs a regression. I have used it for years in versions previous to Excel 2013. The code runs in Excel 2013 but the regression provides no results. I appreciate any help.
Sub Print_Regression()
Dim i As Integer
Dim shtName As String
Dim shtNo As Integer
Application.Goto Reference:="R.Y_Var"
shtName = ActiveSheet.Name
For i = Range("Beginrow").Value To Range("Lastrow").Value
'Clear regression output contents
Application.Goto Reference:="output2"
Selection.ClearContents
'Get regression parameters
Range("Dummyctr").Value = i
Calculate
SendKeys "{F9}", True
'Run new regression
Application.ExecuteExcel4Macro String:= _
"REGRESS(" & shtName & "!R.Y_Var," & shtName & "!R.X" & Range("Mac").Value & _
"_Var,FALSE,FALSE,," & shtName & "!R.Output,FALSE,FALSE,FALSE,FALSE,,FALSE,)"
Application.ScreenUpdating = False
[A1].Select
Calculate
SendKeys "{F9}", True
'Copy regression statistics
Range("M.Copy1").Copy
Range("M.Paste").Offset(0, (i - I_1) * 2).PasteSpecial Paste:=xlValues
Range("M.Copy2").Copy
Range("M.Paste").Offset(1, (i - I_1) * 2).PasteSpecial Paste:=xlValues
'Copy columns to output areas
shtNo = Range("Sht").Value
If Range("V.ExhLabel").Value = "Exhibit 10" Then
Range("V.Fit2Trend").Copy
Range("V.S" & shtNo & "C13").PasteSpecial Paste:=xlValues
Range("V.Fit2Act").Copy
Range("V.S" & shtNo & "C15").PasteSpecial Paste:=xlValues
End If
'Print regression; exhibit
Range("P.Regression").Select
Selection.PrintOut
Next i
Application.CutCopyMode = False
End Sub
Bookmarks