View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Use VBA to get values from named range that contains an array formula expression

Hi James,

It's not clear what you are doing, eg have you created a named range or a
named formula or both, how are you using Index, etc.

I did the following -

Created two dynamic named ranges KnownX & KnownY to refer to cells in
columns A & B

Created a named formula
"nmLinest" refersto: =LINEST(KnownY, KnownX^{1,2})

I entered some X's in col-A, FWIW 1, 2 & 3
For Y's, in B1: =A1^2*2+A1*3+5
and filled down

In VBA -

arr = Evaluate("nmLinest")

For i = 1 To UBound(arr) ' to 3
Debug.Print Application.Index(arr, i)
Next

1.99999999999999
3.00000000000004
4.99999999999997

A tad of rounding would return correct results of 2, 3 & 5 in this contrived
example.

Regards,
Peter T

wrote in message
...
I've used an array formula (linest, as a test) to create an array
formula in an named range by typing the array formula into the Refers
to box on the Define Name pop-up window.

By entering the Index worksheet function in a worksheet cell, I can
access the values in the linest result 'array' but I can't figure out
how to access the values in VBA.

Surely someone has done this, but my best thinking and a lot of
internet searches haven't turned up an answer.

Thanks in advance, even if the answer turns out to be "You can't do
that!" :)

James