Array Declaration Problem ??

M

monir

Hi;

For clarification, the 3rd para. of my latest reply should read:
"The only remaining difficulty is as follows. The array results are
calculated correctly in the array Function Zroots2(), but only the 1st value
of the 1D array Roots results is returned to the col range of cells (instead
of returning the array of results)."

Regards.
 
M

monir

Hi Dana;

Sorry to bother you again, but problem solved at last!!
Here's a summary:

1) On the w/s:
cell B8::3
cell B9:: myTrue
cells B11:B14:: numerical values
cells C11:C14:: numerical values
cells I11:I13:: array formula {=Zroots2(B11:B14,C11:C14,B8,B9)}

Option Base 1
Option Explicit
Function Zroots2 (ar As Range, ai As Range, m As Integer, polish As String)
As String()
Dim EPS As Double
Dim i As Integer, jj As Integer
Dim b As String, c As String
Dim j As Integer, its As Integer
Dim x As String
ReDim Roots(m) As String
ReDim a(m+1) As String, ad(m+1) As String
'.........................................my code1
Zroots2 = Roots()
End Function

3) In Function Zroots2(), array Roots() is calculated correctly, say, [1+i],
[2+2i], [3+3i].
But the array function returned a single value [1+i] to the full range
I11:I13, instead of returning the array 3 results to the 3 vertical cells.

4) In Function Zroots2(), replacing the statement:
Zroots2 = Roots()
with
Zroots2 = WorksheetFunction.Transpose(Roots())
doesn't produce compile error but returns #VALUE! to cells I11:I13

5) Having instead the Transpose function in the array formula on the w/s:
cells I11:I13:: array formula {=Transpose(Zroots2(B11:B14,C11:C14,B8,B9))}
and leaving the Function Zroots2() statement unchanged:
Zroots2 = Roots()
S O L V E S the problem.

I've successfully tested the VBA procedure for 1D polys up to degree 20,
with real and complex coefficients.
If there's interest, I'd be glad to post a demo w/b with the VBA procedure.

Kind regards.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top