Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
transpose matrices
On Fri, 1 Aug 2003 12:58:41 +0200, Ulrik Petersen wrote:
Hi. Does anyone know how to transpose for instance a 2x2 matrix in VBA, Excel 2000? Try this (it's a small procedure, which fills an array, transposes the array and places both 'matrices' into an excel-sheet): Sub Transpose() Dim MyArray(1 To 10, 1 To 10), i As Integer, j As Integer, _ MyArrayTemp(1 To 10, 1 To 10) For i = LBound(MyArray, 1) To UBound(MyArray, 1) For j = LBound(MyArray, 2) To UBound(MyArray, 2) MyArray(i, j) = CInt(Rnd() * 1000) Next j Next i For i = LBound(MyArray, 1) To UBound(MyArray, 1) For j = LBound(MyArray, 2) To UBound(MyArray, 2) MyArrayTemp(j, i) = MyArray(i, j) Next j Next i Range("A1").Activate For i = LBound(MyArray, 1) To UBound(MyArray, 1) For j = LBound(MyArray, 2) To UBound(MyArray, 2) ActiveCell.Offset(i-1, j-1).Value = MyArray(i, j) Next j Next i Range("A15").Activate For i = LBound(MyArray, 1) To UBound(MyArray, 1) For j = LBound(MyArrayTemp, 2) To UBound(MyArrayMyArrayTemp, 2) ActiveCell.Offset(i-1, j-1).Value = MyArrayTemp(i, j) Next j Next i End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how do i square matrices? | Excel Worksheet Functions | |||
inverse matrices | Excel Discussion (Misc queries) | |||
matrices | Excel Discussion (Misc queries) | |||
How to solve y =f(x,y) using matrices? | Excel Worksheet Functions | |||
Combining certain matrices | Excel Discussion (Misc queries) |