Hm, du scheinst meinen Hinweis nicht richtig verstanden zu haben.
Option Explicit
Sub Demo()
Dim a1 As Variant
Dim a2 As Variant
Dim a3 As Variant
a1 = Range("A1:C2").Value
a2 = Range("A1:C1").Value
a3 = Range("A1:A2").Value
Debug.Print "a1", "(rows: " & UBound(a1, 1) & "; cols: " & UBound(a1, 2) & ")"
Debug.Print "a2", "(rows: " & UBound(a2, 1) & "; cols: " & UBound(a2, 2) & ")"
Debug.Print "a3", "(rows: " & UBound(a3, 1) & "; cols: " & UBound(a3, 2) & ")"
a1 = WorksheetFunction.Transpose(a1)
a2 = WorksheetFunction.Transpose(a2)
a3 = WorksheetFunction.Transpose(a3)
Debug.Print "a1^T", "(rows: " & UBound(a1, 1) & "; cols: " & UBound(a1, 2) & ")"
Debug.Print "a2^T", "(rows: " & UBound(a2, 1) & "; cols: " & UBound(a2, 2) & ")"
' Debug.Print "a3_T", "(rows: " & UBound(a3, 1) & "; cols: " & UBound(a3, 2) & ")" 'Laufzeitfehler, da nicht mehr zweidimensional
Debug.Print "a3^T", "(nElem: " & UBound(a3, 1) & ")"
End Sub
Ausgabe ist dann:
a1 (rows: 2; cols: 3)
a2 (rows: 1; cols: 3)
a3 (rows: 2; cols: 1)
a1^T (rows: 3; cols: 2)
a2^T (rows: 3; cols: 1)
a3^T (nElem: 2)
WorksheetFunction.Transpose macht also aus einer Matrix (2D-Array) mit nur eine Spalte, ein 1D-Array.
|