Sub testx1()
Dim t
t = Array("toto la frite", "toto", "fanch55", "patricktoulon")
MsgBox ArrayInTextColumVBTAB2(t)
End Sub
Sub testx2()
Dim t
t = Array("toto", "fanch55", "patricktoulon", "trucmuche", "machin", "blablablablabla")
MsgBox ArrayInTextColumVBTAB2(t)
End Sub
Sub testx3()
Dim t
t = Array("robert", "fanch55", "patricktoulon", "charles", "machin", "henry")
MsgBox ArrayInTextColumVBTAB2(t)
End Sub
Sub testx4()
Dim t
t = Array("camion", "voiture", "poid lourd", "bateau", "canoé", "barque")
MsgBox ArrayInTextColumVBTAB2(t)
End Sub
Function ArrayInTextColumVBTAB2(t)
'patricktoulon
Dim texte$, maxi&, Mask$
minus = Len(Join(t)): maxi = 0
For i = 0 To UBound(t)
If Len(t(i)) > maxi Then maxi = Len(t(i)) 'on determine la longeur de chaine la plus longue
Next
Mask = Application.Rept(" ", maxi + 2)
ReDim t2(UBound(t))
For i = 0 To UBound(t)
t2(i) = Mask 'on met le mask d'espace a chaque tour dans l'item du tableau 2
Mid(t2(i), 1, Len(t(i))) = t(i) 'on met la valeur en lieu et place dans le masck avec mid on garde donc les espaces restants
t2(i) = t2(i) & vbTab & ":aligné" ' et on ajoute enfin la tabulation pour formater les irrégularités des espacement de caracteres selon les mots
Next
Debug.Print Join(t2, vbCrLf)
ArrayInTextColumVBTAB2 = Join(t2, vbCrLf)
End Function