Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Retrieving stats from LINEST

I'm trying to retrieve the r2 from LINESt results via VBA--I don't want to
create a chart and pull it from the chart's trendline. I can retrieve m and b
with no problem, but when I try the following I get an error.

r2 = Application.Evaluate("=index(linest(" & Selection.AddressLocal() &
",,,TRUE),3)")

Any and all help greatly appreciated.
Thanks,
j

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Retrieving stats from LINEST

Here is a working example, with data in A2:E12 (headers in row 1):

Sub TryNow()
Dim myArr As Variant
Dim i As Integer
Dim j As Integer

myArr = Application.WorksheetFunction.LinEst(Range("E2:E12 "), _
Range("A2:D12"), True, True)

MsgBox "R2 stat is " & myArr(3, 1)

If MsgBox("Want other values?", vbYesNo) = vbYes Then
For i = LBound(myArr, 1) To UBound(myArr, 1)
For j = LBound(myArr, 2) To UBound(myArr, 2)
MsgBox "Row " & i & ", Column " & j & " of the returned array is " _
& IIf(IsError(myArr(i, j)), "an error", myArr(i, j))
Next j
Next i
End If
End Sub

HTH,
Bernie
MS Excel MVP


"jstansbury" (nonotspam) wrote in message
...
I'm trying to retrieve the r2 from LINESt results via VBA--I don't want to
create a chart and pull it from the chart's trendline. I can retrieve m and b
with no problem, but when I try the following I get an error.

r2 = Application.Evaluate("=index(linest(" & Selection.AddressLocal() &
",,,TRUE),3)")

Any and all help greatly appreciated.
Thanks,
j



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Retrieving stats from LINEST

Bernie,
Works like a charm. Thank you very much!
Much appreciated,
j


"Bernie Deitrick" wrote:

Here is a working example, with data in A2:E12 (headers in row 1):

Sub TryNow()
Dim myArr As Variant
Dim i As Integer
Dim j As Integer

myArr = Application.WorksheetFunction.LinEst(Range("E2:E12 "), _
Range("A2:D12"), True, True)

MsgBox "R2 stat is " & myArr(3, 1)

If MsgBox("Want other values?", vbYesNo) = vbYes Then
For i = LBound(myArr, 1) To UBound(myArr, 1)
For j = LBound(myArr, 2) To UBound(myArr, 2)
MsgBox "Row " & i & ", Column " & j & " of the returned array is " _
& IIf(IsError(myArr(i, j)), "an error", myArr(i, j))
Next j
Next i
End If
End Sub

HTH,
Bernie
MS Excel MVP


"jstansbury" (nonotspam) wrote in message
...
I'm trying to retrieve the r2 from LINESt results via VBA--I don't want to
create a chart and pull it from the chart's trendline. I can retrieve m and b
with no problem, but when I try the following I get an error.

r2 = Application.Evaluate("=index(linest(" & Selection.AddressLocal() &
",,,TRUE),3)")

Any and all help greatly appreciated.
Thanks,
j




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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Historical Stats mpenkala Excel Discussion (Misc queries) 1 April 2nd 09 08:26 PM
still need help refreshing Web stats Walter Excel Discussion (Misc queries) 1 February 27th 08 12:09 AM
Creating stats mercedes Excel Discussion (Misc queries) 3 December 8th 06 05:28 PM
How do I get LINEST to show all stats? telespiza Excel Worksheet Functions 2 November 10th 05 02:46 AM
Stats Question ExcelMonkey[_45_] Excel Programming 3 January 30th 04 04:42 AM


All times are GMT +1. The time now is 04:19 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"