Option Explicit
Sub DécroiserTableau() '
'décroiser un tableau pour remettre en colonne et en faire un tcd
Dim a, b(), i As Long, j As Long, n As Long
a = Sheets("Onglet1").[a1].CurrentRegion.Value2 ' Nom de l'onglet à adapter ' mise en mémoire
ReDim b(1 To (UBound(a, 1) - 1) * (UBound(a, 2) - 1), 1 To 5)
For i = 2 To UBound(a, 1) ' hauteur de la zone
For j = 2 To UBound(a, 2) ' largeur de la zone
If Not IsEmpty(a(i, j)) Then ' si pas vide
n = n + 1 ' incrémenter ligne
b(n, 1) = a(i, 1) ' mettre data dans 1ere colonne
b(n, 2) = a(1, j) ' 2e colonne
b(n, 3) = a(i, j) ' 3e colonne
End If
Next
Next
Application.ScreenUpdating = False
'Restitution
With Sheets("feuil1").Cells(1).Resize(, 4) ' 3 colonnes partant de la A ! nom de l'onglet à adapter
.CurrentRegion.Clear ' effacer la feuille
With .Offset(1).Resize(n)
.FormulaLocal = b ' coller le tableau
End With
End With
Application.ScreenUpdating = True
End Sub