Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all,
I have written vbs codes to run a linear regression – 5 independent variables. I want to get regression result print in the spreadsheet where the data is and the statistics for regression are the same as result from analysis tool package… I know Regression= Application.LinEst(y, x, True, True) should be use, but no idea how to get regression output to a spreadsheet.Could someone please provide some solutions? Thanks a ton Fei |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How about just plopping the =linest() formula directly into the range on the
worksheet. You could record a macro when you do it manually: dim DestCell as range set destcell = worksheets("Sheet999").range("x99") destcell.resize(5,2).formulaarray = "=linest(....)" Fei wrote: Hi all, I have written vbs codes to run a linear regression – 5 independent variables. I want to get regression result print in the spreadsheet where the data is and the statistics for regression are the same as result from analysis tool package… I know Regression= Application.LinEst(y, x, True, True) should be use, but no idea how to get regression output to a spreadsheet.Could someone please provide some solutions? Thanks a ton Fei -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Dave.
VBA code is preferred, as I run regressions for different worksheets... |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I don't understand. You can use VBA code to populate the cells with a formula.
You could even convert the results of the formula to values. But if you want: Option Explicit Sub Testme() Dim Xs As Variant Dim Ys As Variant Dim res As Variant Dim HowManyRows As Long Dim HowManyCols As Long Dim DestCell As Range With ActiveSheet 'test data and the topleftcell of the result range. Xs = .Range("b1:b10").Value Ys = .Range("a1:a10").Value Set DestCell = .Range("f9") End With res = Application.LinEst(Xs, Ys, , True) HowManyRows = UBound(res, 1) - LBound(res, 1) + 1 HowManyCols = UBound(res, 2) - LBound(res, 2) + 1 DestCell.Resize(HowManyRows, HowManyCols).Value = res End Sub Fei wrote: Thanks Dave. VBA code is preferred, as I run regressions for different worksheets... -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
My excel spreadsheet won't print or print preview all the pages? | Excel Worksheet Functions | |||
how to use linest to get the result as ARRAY? | Excel Worksheet Functions | |||
r2 result in LINEST Excel 97 v Excel 2003 | Excel Discussion (Misc queries) | |||
How do I extract a single value from the linest array result? | Excel Worksheet Functions | |||
One spreadsheet cell won't print but shows up in print preview? | Excel Discussion (Misc queries) |