View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
levent levent is offline
external usenet poster
 
Posts: 6
Default application.run for returning arrays

i have tried to use what you suggested with the functions
of Matrix.xla. And it worked for some of them. However,
for others, it goes into the matrix.xla programs and gives
some errors.

i don't know if one could tell why just by looking at
this, i could also send the relevant code for Matrix.xla.
but it is not mine and it is not very short. (so how
should i send it?)


Sub Main()
Dim A(1 To 5, 1 To 5)
Dim ws As Worksheet

Set ws = Worksheets("Markov ex")
For i = 1 To 5
For j = 1 To 5
A(i, j) = ws.Cells(i + 2, j)
'MsgBox A(i, j)
Next j
Next i

c = Application.Run("MATRIX.XLA!MatCharPoly", A) 'DOES
NOT WORK
'should return VECTOR
'object required ERROR
'in MATRIX.XLA,
'If Application.Caller.Rows.Count 1 Then

s = Application.Run("MATRIX.XLA!MatEigenValue_QR",
A) 'DOES WORK
'returns 5x2 works FINE


Dim s1 As Variant
'first row of s
s1 = Array(s(1, 1), s(1, 2))


ev1 = Application.Run("MATRIX.XLA!MatEigenVector_C",
A, s1) 'DOES NOT WORK
'should return 5x2
'subscript out of range ERROR
'Lr = Eigenvalue(1, 1)

End Sub
-----Original Message-----
hi

with regard to accessing excel functions from VBA,
i have learned (at this forum) that you can do the
following:

a = Application.Run("ATPVBAEN.XLA!IMPRODUCT", A, b)

(when the excel function returns a single value)

however, when i try to do this for an excel function that
returns an ARRAY, it does not work. (there is an add-in
that does matrix operations e.g. matrix inversion, so

both
inputs and output is a two-dimensional array)

is there a way to do this without having to dump things
into excel and input from excel again?

.