ExcelVBA编程实现多元线性回归( 二 )

<> "" ThenActiveWorkbook.Sheets(1).Range(addx).Cells(i, 1).Offset(0, 3).Value = http://kandian.youth.cn/index/Application.WorksheetFunction.Transpose(Evaluate("=" & UserForm1.fxn1.Text))(i)End IfIf UserForm1.fxn2.Text <> "" ThenActiveWorkbook.Sheets(1).Range(addx).Cells(i, 1).Offset(0, 3).Value = http://kandian.youth.cn/index/Application.WorksheetFunction.Transpose(Evaluate("=" & UserForm1.fxn2.Text))(i)End IfIf UserForm1.fxn3.Text <> "" ThenActiveWorkbook.Sheets(1).Range(addx).Cells(i, 1).Offset(0, 3).Value = http://kandian.youth.cn/index/Application.WorksheetFunction.Transpose(Evaluate("=" & UserForm1.fxn3.Text))(i)End IfIf UserForm1.fxn4.Text <> "" ThenActiveWorkbook.Sheets(1).Range(addx).Cells(i, 1).Offset(0, 3).Value = http://kandian.youth.cn/index/Application.WorksheetFunction.Transpose(Evaluate("=" & UserForm1.fxn4.Text))(i)End Ifx(i, 2) = ActiveWorkbook.Sheets(1).Range(addx).Cells(i, 1).Offset(0, 3).Valuey(i, 1) = ActiveWorkbook.Sheets(1).Range(addy).Cells(i, 1)Next ixt = Application.WorksheetFunction.Transpose(x)xtx = Application.WorksheetFunction.MMult(xt, x)xty = Application.WorksheetFunction.MMult(xt, y)xtxi = Application.WorksheetFunction.MInverse(xtx)beta = Application.WorksheetFunction.MMult(xtxi, xty)yp = Application.WorksheetFunction.MMult(x, beta)For i = 1 To numxActiveWorkbook.Sheets(1).Cells(i, 3).Value = http://kandian.youth.cn/index/yp(i, 1)Next iEnd IfIf nterm = 2 ThenReDim x(numx, 3) As Variant, y(numx, 1) As VariantFor i = 1 To numxx(i, 1) = 1If UserForm1.fxn1.Text <> "" ThenActiveWorkbook.Sheets(1).Range(addx).Cells(i, 1).Offset(0, 3).Value = http://kandian.youth.cn/index/Application.WorksheetFunction.Transpose(Evaluate("=" & UserForm1.fxn1.Text))(i)If UserForm1.fxn2.Text <> "" ThenActiveWorkbook.Sheets(1).Range(addx).Cells(i, 1).Offset(0, 4).Value = http://kandian.youth.cn/index/Application.WorksheetFunction.Transpose(Evaluate("=" & UserForm1.fxn2.Text))(i)End IfIf UserForm1.fxn3.Text <> "" ThenActiveWorkbook.Sheets(1).Range(addx).Cells(i, 1).Offset(0, 4).Value = http://kandian.youth.cn/index/Application.WorksheetFunction.Transpose(Evaluate("=" & UserForm1.fxn3.Text))(i)End IfIf UserForm1.fxn4.Text <> "" ThenActiveWorkbook.Sheets(1).Range(addx).Cells(i, 1).Offset(0, 4).Value = http://kandian.youth.cn/index/Application.WorksheetFunction.Transpose(Evaluate("=" & UserForm1.fxn4.Text))(i)End IfEnd IfIf UserForm1.fxn2.Text <> "" And UserForm1.fxn3.Text <> "" ThenActiveWorkbook.Sheets(1).Range(addx).Cells(i, 1).Offset(0, 3).Value = http://kandian.youth.cn/index/Application.WorksheetFunction.Transpose(Evaluate("=" & UserForm1.fxn2.Text))(i)ActiveWorkbook.Sheets(1).Range(addx).Cells(i, 1).Offset(0, 4).Value = http://kandian.youth.cn/index/Application.WorksheetFunction.Transpose(Evaluate("=" & UserForm1.fxn3.Text))(i)End IfIf UserForm1.fxn4.Text <> "" And UserForm1.fxn2.Text <> "" ThenActiveWorkbook.Sheets(1).Range(addx).Cells(i, 1).Offset(0, 4).Value = http://kandian.youth.cn/index/Application.WorksheetFunction.Transpose(Evaluate("=" & UserForm1.fxn4.Text))(i)ActiveWorkbook.Sheets(1).Range(addx).Cells(i, 1).Offset(0, 3).Value = http://kandian.youth.cn/index/Application.WorksheetFunction.Transpose(Evaluate("=" & UserForm1.fxn2.Text))(i)End IfIf UserForm1.fxn3.Text


推荐阅读