INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Matrix Inverse in VBA Excel

RE: Matrix Inverse in VBA Excel

Two changes will get it working:

1. Your matrix does not have an inverse (check it with MInverse on the spreadsheet). I have changed the value at (3,3) to -33 to fix that.

2. You can't assign an array to a double array. You need to declare Tstr as a variant: Public Tstr As Variant

With those two changes it will work.

A few other points:
3. It is better to declare all integers as long, because VBA converts integers to long anyway, and if you always use long you don't need to think about whether to use integer or long.

4. You can return the result array to the spreadsheet in a single operation, rather than calling the check function 9 times (which calls the inverse sub 9 times. so:

CODE --> VBA

Function Check2()
Call MomD
Check2 = Tstr
End Function 

will return the full array. When you enter the function you will only see (1,1) of course. To see the whole array:
Select a 3x3 range, with the function in the top left corner
Press F2
Press Ctrl-shift-enter

5. You can pass a worksheet range, do the inverse, and return the result in a single function:

CODE --> VBA

Function Check3(mrange As Variant)
Check3 = WorksheetFunction.MInverse(mrange)
End Function 

Doug Jenkins
Interactive Design Services
http://newtonexcelbach.wordpress.com/

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close