Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

About array matrix function

  Asked By: Ernesta    Date: Nov 18    Category: MS Office    Views: 1095
  

I ran the following, but the system gave me err "unable to get the Minverse
property of the worksheet function class". Anyone know what happened with that?


Sub Solutions()
q = Range("e12").Value

'define array temprate
Dim temprate() As Double
ReDim temprate(q, q)
For k = 0 To q - 1
For h = 0 To q - 1
temprate(k, h) = Cells(13 + k, 27 + q + h).Value
Next h
Next k

'Define array extrate
Dim Extrate() As Double
ReDim Extrate(q)
For k = 0 To q - 1
Extrate(k) = Cells(12 + k + 1, 27 + 2 * q).Value
Next k

'calculation
Dim results() As Double
ReDim results(q) As Double
For k = 0 To q - 1
results(k) =
Application.WorksheetFunction.MMult(Application.WorksheetFunction.MInverse(tempr\
ate()), Extrate)
Next k

End Sub

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Yvette Griffin     Answered On: Nov 18

I'd like to bet that it's a non invertable matrix  because, for example
if E12 contains the value 3, the matrix 'temprate' you're trying to
invert is 4 x 4 with zeroes all along the bottom and right hand side.
(Changing the bottom right member from 0 to 1 changed the error to
'Type mismatch', and worked on the sheet too.)

Try setting
Option Base 1
or ReDim temprate(q-1,q-1)
(along with the other arrays)

I didn't solve the type mismatch though, but you should be one step
further..

 
Answer #2    Answered By: Brent Brown     Answered On: Nov 18

Also I ran into 'Unable to get the MMult property..' which I suspect
is solvable by
Application.WorksheetFunction.Transpose(Extrate)
instead of
Extrate
in the bothersome line.

because MMULT requires that 'the number of columns in array1 must be
the same as the number of rows in array2', and I *think* that vba
sees array2 as a single row horizontal array.

THEN I get the type mismatch again...

Running out of time now, one shot in the dark though; does this need
to be a loop? Would
results() = Application.Worksh....
work rather than
results(k) = Application.Worksh...
?

 
Didn't find what you were looking for? Find more on About array matrix function Or get search suggestion and latest updates.




Tagged: