#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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






  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:32 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"