View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Jerry W. Lewis
 
Posts: n/a
Default Correlation-Coefficient

Sub RSQ()
Dim Rng As Variant
Rng = Selection
Range("G10").FormulaArray = "= RSQ(" & Selection.Address & ",ROW(" &
Selection.Address & "))": _
Range("G10") = Range("G10").Value
' I want to replace C2:C11 with Rng in the line above
End Sub

Your terminology is not exactly correct. RSQ is the square of the
correlation coefficient. Also, in Excel versions prior to 2003, CORREL()^2
is numerically better
than RSQ().

Jerry

"daniel chen" wrote:

The following macro is to find the Linear Correlation-Coefficient
of a selected range. I'd like to use a Selection "Rng" instead of
a fixed range "C2:C11"
Can it be done?

Sub RSQ()
Dim Rng As Variant
Rng = Selection
Range("G10") = "= RSQ(C2:C11,ROW(C2:C11))": _
Range("G10") = Range("G10").Value
' I want to replace C2:C11 with Rng in the line above
End Sub