# VBA - How to Transpose a 2 dimensional array?

#### bomvoo

##### New Member
Does anybody know a quick way to transpose a 2 dimensional array?

Below is an example of the problem:

Code:
``````dim T(1 TO 3, 1 TO 2) as double
dim TT(1 TO 2, 1 TO 3) as double

T(1,1)=1.6
T(1,2)=1.5
T(2,1)=2.4
T(2,2)=2.6
T(3,1)=0.2
T(3,2)=0.5

'The question is if anybody knows a function like this:
TT= transpose(T)

'Such that
'TT(1,1)=1.6  (T(1,1))
'TT(1,2)=2.4  (T(2,1))
'TT(1,3)=0.2  (T(3,1))
'TT(2,1)=1.5  (T(1,2))
'TT(2,2)=2.6  (T(2,2))
'TT(2,3)=0.5  (T(3,2))

end sub``````

Regards,
Eduardo

### Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Try this.
Code:
``````Dim T(1 To 3, 1 To 2) As Double
Dim TT

T(1, 1) = 1.6
T(1, 2) = 1.5
T(2, 1) = 2.4
T(2, 2) = 2.6
T(3, 1) = 0.2
T(3, 2) = 0.5

TT = Application.WorksheetFunction.Transpose(T)``````

Eduardo

You can do this using Application.Worksheetfunction.Transpose, but I think you may have to use a variant variable when you are assigning the transposition ie:

Code:
``````Dim TT as Variant
....
TT = Application.WorksheetFunction.Transpose(T)``````

Best regards

Richard

Replies
41
Views
5K
Replies
6
Views
351
Replies
2
Views
704
Replies
2
Views
354
Replies
4
Views
571

1,221,508
Messages
6,160,222
Members
451,631
Latest member
coffiajoseph

### 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.

### Which adblocker are you using?

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

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