example
From a previous post:
From: Tom Ogilvy ) Subject: LINEST worksheet function with VBA for polynomials Newsgroups: microsoft.public.excel.programming Date: 2003-06-27 12:45:21 PST An easy way is to use evaluate: Sub dolinest() varr = Evaluate("LINEST(C22:C25,A22:A25^{1,2})") For i = LBound(varr) To UBound(varr) Debug.Print Application.Round(varr(i), 2) Next End Sub Otherwise, you would need to build the array of x-values Sub dolinest1() Dim varr(1 To 4, 1 To 2) Set rng = Range("A22") For i = 1 To 4 varr(i, 1) = rng(i, 1) ^ 1 varr(i, 2) = rng(i, 1) ^ 2 Next varr1 = WorksheetFunction.LinEst(Range("C22:C25"), varr) For i = LBound(varr1) To UBound(varr1) Debug.Print Application.Round(varr1(i), 2) Next End Sub Regards, Tom Ogilvy -------------------Is that what you mean? "Don Cossitt" wrote in message ... Forgot to give an example... If I have a Range(...) of values from a worksheet; how would one retrieve the results of, for instance, LINEST(knownYs, knownXs^{1,2,3}), in VBA? Thanks Donald R. Cossitt "Don Cossitt" wrote in message ... Hello; Does anyone know of a source for retrieving the resulting terms of a Polynomial(3) regression in VBA? TIA Donald R. Cossitt |
example
Yes indeed! Thank you.
Donald R. Cossitt "Tom Ogilvy" wrote in message ... From a previous post: From: Tom Ogilvy ) Subject: LINEST worksheet function with VBA for polynomials Newsgroups: microsoft.public.excel.programming Date: 2003-06-27 12:45:21 PST An easy way is to use evaluate: Sub dolinest() varr = Evaluate("LINEST(C22:C25,A22:A25^{1,2})") For i = LBound(varr) To UBound(varr) Debug.Print Application.Round(varr(i), 2) Next End Sub Otherwise, you would need to build the array of x-values Sub dolinest1() Dim varr(1 To 4, 1 To 2) Set rng = Range("A22") For i = 1 To 4 varr(i, 1) = rng(i, 1) ^ 1 varr(i, 2) = rng(i, 1) ^ 2 Next varr1 = WorksheetFunction.LinEst(Range("C22:C25"), varr) For i = LBound(varr1) To UBound(varr1) Debug.Print Application.Round(varr1(i), 2) Next End Sub Regards, Tom Ogilvy -------------------Is that what you mean? "Don Cossitt" wrote in message ... Forgot to give an example... If I have a Range(...) of values from a worksheet; how would one retrieve the results of, for instance, LINEST(knownYs, knownXs^{1,2,3}), in VBA? Thanks Donald R. Cossitt "Don Cossitt" wrote in message ... Hello; Does anyone know of a source for retrieving the resulting terms of a Polynomial(3) regression in VBA? TIA Donald R. Cossitt |
All times are GMT +1. The time now is 12:52 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com