'VERSION 1
Function TransposeXV1(T, Optional lBase& = -1)
'patricktoulon V 1.2 -- 08/07/2021
'Ajout du change base V 1.2.1 -- 08/12/2024 méthode Addition nombre relatif
Dim y&, i&, c&, T2(), LB1%, LB2%
If lBase > 1 Then lBase = 1 ' au cas ou il vous prendrez l'envie de faire nimporte quoi
On Error Resume Next
y = UBound(T, 2)
On Error GoTo 0
'b1 et b2 deviendront les reducteurs ou augmenteur de dimension (++/+-)
If lBase > -1 Then LB1 = Sgn(lBase - LBound(T))
If y = 0 Then
ReDim T2(LBound(T) + LB1 To UBound(T) +LB1, LBound(T) + LB1 To LBound(T) + LB1)
Else
If lBase > -1 Then LB2 = Sgn(lBase - LBound(T, 2))
ReDim T2(LBound(T, 2) + LB2 To UBound(T, 2) + LB2, LBound(T) + LB1 To UBound(T) + LB1)
End If
For i = LBound(T) To UBound(T)
If y = 0 Then
T2(i + LB1, 1) = T(i)
Else
For c = LBound(T, 2) To UBound(T, 2)
T2(c + LB2, i + LB2) = T(i, c)
Next
End If
Next
TransposeXV1 = T2
End Function
'VERSION 2
Function TransposeXV2(T, Optional lBase& = -1)
'Ajout du change base V 1.2.1 -- 08/12/2024 méthode Addition nombre relatif en select case
'patricktoulon V 1.3 -- 10/12/2024
'version 1.3 avec un select case
Dim y&, i&, c&, T2(), LB1%, LB2%
If TypeOf T Is Range Then T = T.Value
If lBase > 1 Then lBase = 1 ' au cas ou il vous prendrez l'envie de faire nimporte quoi
On Error Resume Next
y = UBound(T, 2)
'b1 et b2 deviendront les reducteurs ou augmenteur de dimension (++/+-)
Select Case True
Case Err.Number <> 0
If lBase > -1 Then LB1 = Sgn(lBase - LBound(T))
ReDim T2(LBound(T) + LB1 To UBound(T) +LB1, LBound(T) + LB1 To LBound(T) + LB1)
For i = LBound(T) To UBound(T): T2(i + LB1, 1) = T(i): Next
On Error GoTo 0
Case Else
If lBase > -1 Then LB2 = Sgn(lBase - LBound(T, 2))
ReDim T2(LBound(T, 2) + LB2 To UBound(T, 2) + LB2, LBound(T) + LB1 To UBound(T) + LB1)
For i = LBound(T) To UBound(T)
For c = LBound(T, 2) To UBound(T, 2): T2(c + LB2, i + LB2) = T(i, c): Next
Next
End Select
TransposeXV2 = T2
End Function