#1   Report Post  
Posted to microsoft.public.excel.misc
Jeff
 
Posts: n/a
Default VBA Ussing Arrays

I have an array in VBA, and I want to find the inverse using the

"MINVERSE", but I want to do this in VBA, and not use values from the
worksheet.

Sub MatrixFormuls()

Dim Array1(2, 2), Array2(2, 1), Array3(2, 2), Array4(2, 1), X(2, 2) As Double

Array1(1, 1) = 3
Array1(1, 2) = 4
Array1(2, 1) = 4
Array1(2, 2) = 8

Array2(1, 1) = 8
Array2(2, 1) = 1

'Array3(1, 1) = Application.Index(Application.MInverse(Array1), 1, 1)
X(1, 1) = Application.MInverse(Array1(2, 2))


I am trying to set X = to the inverse of Array1(2,2)

Since X will have 4 values = a 2 x 2 array I want to use the "Index"
function to get each of the inverse values and assign it to a 2x2 array.

My current code does not work

Thanks for your help
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dana DeLouis
 
Posts: n/a
Default VBA Ussing Arrays

Dim Array1(2, 2),

Hi. As a technique, as you step thru your code, pull up the "Locals
Window." You will see that your lower bound of Array1 is 0, and probably
not your expected value of 1.
Perhaps one of a few ways...

Sub MatrixFormuls()
Dim Array1(1 To 2, 1 To 2)
Dim X As Variant

Array1(1, 1) = 3
Array1(1, 2) = 4
Array1(2, 1) = 4
Array1(2, 2) = 8

X = WorksheetFunction.MInverse(Array1)
End Sub

HTH. :)
--
Dana DeLouis
Win XP & Office 2003


"Jeff" wrote in message
...
I have an array in VBA, and I want to find the inverse using the

"MINVERSE", but I want to do this in VBA, and not use values from the
worksheet.

Sub MatrixFormuls()

Dim Array1(2, 2), Array2(2, 1), Array3(2, 2), Array4(2, 1), X(2, 2) As
Double

Array1(1, 1) = 3
Array1(1, 2) = 4
Array1(2, 1) = 4
Array1(2, 2) = 8

Array2(1, 1) = 8
Array2(2, 1) = 1

'Array3(1, 1) = Application.Index(Application.MInverse(Array1), 1, 1)
X(1, 1) = Application.MInverse(Array1(2, 2))


I am trying to set X = to the inverse of Array1(2,2)

Since X will have 4 values = a 2 x 2 array I want to use the "Index"
function to get each of the inverse values and assign it to a 2x2 array.

My current code does not work

Thanks for your help



  #3   Report Post  
Posted to microsoft.public.excel.misc
Dana DeLouis
 
Posts: n/a
Default VBA Ussing Arrays

Forgot to mention...If you would like a slightly different approach for
small arrays...

Sub Demo()
Dim Array1, X

Array1 = [{3,4;4,8}]
X = WorksheetFunction.MInverse(Array1)
End Sub

HTH ;)
--
Dana DeLouis
Win XP & Office 2003


"Dana DeLouis" wrote in message
...
Dim Array1(2, 2),


Hi. As a technique, as you step thru your code, pull up the "Locals
Window." You will see that your lower bound of Array1 is 0, and probably
not your expected value of 1.
Perhaps one of a few ways...

Sub MatrixFormuls()
Dim Array1(1 To 2, 1 To 2)
Dim X As Variant

Array1(1, 1) = 3
Array1(1, 2) = 4
Array1(2, 1) = 4
Array1(2, 2) = 8

X = WorksheetFunction.MInverse(Array1)
End Sub

HTH. :)
--
Dana DeLouis
Win XP & Office 2003


"Jeff" wrote in message
...
I have an array in VBA, and I want to find the inverse using the

"MINVERSE", but I want to do this in VBA, and not use values from the
worksheet.

Sub MatrixFormuls()

Dim Array1(2, 2), Array2(2, 1), Array3(2, 2), Array4(2, 1), X(2, 2) As
Double

Array1(1, 1) = 3
Array1(1, 2) = 4
Array1(2, 1) = 4
Array1(2, 2) = 8

Array2(1, 1) = 8
Array2(2, 1) = 1

'Array3(1, 1) = Application.Index(Application.MInverse(Array1), 1, 1)
X(1, 1) = Application.MInverse(Array1(2, 2))


I am trying to set X = to the inverse of Array1(2,2)

Since X will have 4 values = a 2 x 2 array I want to use the "Index"
function to get each of the inverse values and assign it to a 2x2 array.

My current code does not work

Thanks for your help



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
vba adding arrays Jeff Excel Discussion (Misc queries) 1 November 4th 05 02:50 PM
Confused about arrays and ranges in functions Llurker Excel Worksheet Functions 0 July 7th 05 05:44 AM
Comparing Arrays TangentMemory Excel Discussion (Misc queries) 2 May 13th 05 05:06 PM
How to use linest with variably sized data arrays? [email protected] Excel Worksheet Functions 0 April 13th 05 04:56 PM
Comparing Arrays KL Excel Worksheet Functions 9 December 3rd 04 08:58 PM


All times are GMT +1. The time now is 08:24 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"