Multidimensional Array problem

stuckinthemiddle

New Member
Joined
May 22, 2005
Messages
8
This need to be written in vba as speed is essential.
This is what I am trying to achieve. I wish to start at the top row of data and loop through the data from row 2 to row end of data, you will see on the spreadsheet that I have highlighted 2 matrices. Now here comes the tricky bit for me, I wish to insert data into 2 matrices, the matrices I have shown are 3dimensional for ease however this changes for each pass that I do and eventually the last pass has 8 dimensions all matrices are square so as you can see we start with 3X3 and end with 8X8. This mean that the matrices cannot be fixed sizes hence some of the problem I have to deal with. Next as the data is inserted into each mtrix as shown each row of data has a multiplying factor which is shown in bold for each row of data. ie

I have used the actual cell reference for the data symbol
Matrix A
((I2) (J2) (k2))*H2
((M2) (N2) (O2))*L2
((Q2) (R2) (S2))*P2

Matrix B
((U2) (V2) (W2))*T2
((Y2) (Z2) (AA2))*X2
((AC2) (AD2) (AE2))*AB2

next I need to find the determinant for each matrix and then again multiply each determinant by a factor which is determined by a for next loop. I know that this is not a trivial task and I do hope that you can help I have enclosed some further notes below to help with the spreadsheet, if you need any further assistance please email me for clarification.


You will see that I have enclosed a spreadsheet to help you. At the top left you can see a comment box stating Matrix A, below in rows 2,3 and 4 are data. If you select each data cell there is a reference to the cell that the data is situated. I have formatted the cells appropriately for ease. You will also see that there is a similar Matrix,matrix B starting at rows 16,17 and 18.

Both of the Matrix data is from the first row(Row 2). The data is to be inserted into the matrix as shown and each row of data is to be multiplied by the data in the corresponding bold font for each row,ie row2 data in the matrix is to be multiplied by column H, row3 data by columnL and row4 data by column p. For matrix B you will see that I have placed a multiplication symbol(*) in column D and that in column E there is data, again if you select the cell you can see where the data is situated on the sheet and again the data in the matrix is to be multiplied by this data.
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Hi
Matrix A
((I2) (J2) (k2))*H2
((M2) (N2) (O2))*L2
((Q2) (R2) (S2))*P2

Matrix B
((U2) (V2) (W2))*T2
((Y2) (Z2) (AA2))*X2
((AC2) (AD2) (AE2))*AB2

2 two dimension arrays.

in row1 of the array
do you want like

(I2),(J2),(k2).((I2)+(J2)+(k2))*H2 ?

then what do you wnat to do with them after completed?
 
Upvote 0
Oh so many questions... :confused: Where are H2, L2, etc. coming from? Were they previously a column matrix (thus your matrix rows are transposed)? Are you trying to ultimately find eigenvalues?
this changes for each pass
How so?

Finding determinants shouldn't be all too bad really, perhaps just time consuming to construct for an 8x8.

Sorry, but I'm gonna stop there. Some serious clarification needs to be made, friend.

Check out the free HTML Maker link on the first page of this forum. If you decide to post your sheet using this tool, remember to use the View Code option, and then post the code into the body of your message.
 
Upvote 0
Hi

Try the code
Code:
Sub matrix()
Dim a(1 To 3, 1 To 4), b(1 To 3, 1 To 4), i As Integer, ii As Integer, iii As Integer
With Sheets("sheet1")
    For i = 1 To 3
        For ii = 1 To 3
            a(i, ii) = .Cells(2, ii + 8 + iii)
        Next
        a(i, 4) = a(i, 1) * a(i, 2) * a(i, 3) * .Cells(2, 8 + iii)
        iii = iii + 4
    Next
    iii = 0
    For i = 1 To 3
        For ii = 1 To 3
            b(i, ii) = .Cells(2, ii + 20 + iii)
        Next
        b(i, 4) = b(i, 1) * b(i, 2) * b(i, 3) * .Cells(2, 20 + iii)
        iii = iii + 4
    Next
    .Range("d2").Resize(UBound(a, 1), UBound(a, 2)).Value = a
    .Range("d2").End(xlDown).Offset(2).Resize(UBound(b, 1), UBound(b, 2)).Value = b
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,523
Messages
6,120,039
Members
448,940
Latest member
mdusw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top