Hi Mr. or Ms. Anonymous,
I need the code in VBA to calculate the determinant value of a matrix.
Below, a code for calculation determinant value of 2X2 matrix.

Any suggestion?

Respectfully yours,
ASD

* * *

Private Function MyFunction_MDETERM(Range As Variant)
'function returns the matrix determinant of an array

Dim perm() As Integer
Dim a() As Integer
MyFunction_MDETERM = "Eror"
NoPermutation = Range.Rows.Count

If NoPermutation < 2 Or Range.Rows.Count <> Range.Columns.Count Then
Exit Function

If NoPermutation > 2 Then
  MyFunction_MDETERM = "Err - To big!"
  Exit Function
End If

ReDim a(NoPermutation, NoPermutation)

If NoPermutation = 2 Then
  MyFunction_MDETERM = a(1, 1) * a(2, 2) - a(1, 2) * a(2, 1)
  Exit Function
End If

End Function

--~--~---------~--~----~------------~-------~--~----~
Visit the blog to download Excel tutorials at 
http://www.excel-macros.blogspot.com

To post to this group, send email to excel-macros@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/excel-macros?hl=en

Visit & Join Our Orkut Community at 
http://www.orkut.com/Community.aspx?cmm=22913620

Visit the blog to download Excel tutorials at 
http://www.excel-macros.blogspot.com

To Learn VBA Macros Please visit http://www.vbamacros.blogspot.com

To see the Daily Excel Tips, Go to:
http://exceldailytip.blogspot.com
-~----------~----~----~----~------~----~------~--~---

Reply via email to