Matrix Inverse in VBA Excel
Matrix Inverse in VBA Excel
(OP)
Matrix Inverse operation in VBA is not working in my attached Excel sheet.
Can any body please review and help me.
With Regards
Probal
Can any body please review and help me.
With Regards
Probal





RE: Matrix Inverse in VBA Excel
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
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
Doug Jenkins
Interactive Design Services
http://newtonexcelbach.wordpress.com/