Using LinEst function within VBA macro

R

RyanVM

I'm trying to perform a LinEst calculation (best fine line) within a VB
macro so I can use the resulting slope value for some othe
calculations.

As best as I can tell, I should be setting it up like this:

Code
-------------------
Value = Application.WorksheetFunction.LinEst(A1:A10,C1:C10
-------------------
However, when I try to compile this function, I get the followin
error:

Code
-------------------
Compile error:

Expected: list separator or
-------------------
I tried enclosing the ranges with quotes, but that didn't work either.
I could create a cell with the LinEst function in it then copy th
value, but that seems like a rather inefficient way for doing it.

Does anyone have an idea of how to make it work
 
T

Tom Ogilvy

Dim vValue as Variant
vValue =
Application.WorksheetFunction.LinEst(Range("A1:A10"),Range("C1:C10"))

I didn't check your syntax, but as a minimum, you need to use range object
where you would use ranges in Excel.

I have posted serveral examples of using LinEst in VBA in the past. Search
google groups for examples.

http://groups.google.com/advanced_group_search?hl=en
 
Top