Comment transposer les cellules

Bonjour, je chercher désespérément, comment transposer les cellules comportant plusieurs mêmes valeurs dans la colonne A et les transposer en horizontal sur la même ligne.

Voir pièce jointe.

8test-excel.xlsx (19.19 Ko)

Bonjour,

à tester,

Sub test()
Set sh1 = Sheets("test")
Set sh2 = Sheets("résultat")

rw1 = sh1.Cells(Rows.Count, 1).End(xlUp).Row
rw2 = sh2.Cells(Rows.Count, 1).End(xlUp).Row + 1

For i = 2 To rw1
    If Application.CountIf(sh2.Range("A:A"), sh1.Cells(i, "A")) = 0 Then
        sh2.Range("A" & rw2 & ":E" & rw2) = sh1.Range("A" & i & ":G" & i).Value
        rw2 = sh2.Cells(Rows.Count, 1).End(xlUp).Row + 1
    Else
        ligne = Application.Match(sh1.Cells(i, "A"), sh2.Range("A:A"), 0)
        col = sh2.Cells(ligne, Columns.Count).End(xlToLeft).Column + 1
        plgDest = Range(Cells(ligne, col).Address, Cells(ligne, col + 3).Address).Address
        plgOrig = Range("B" & i & ":G" & i).Address
        sh2.Range(plgDest) = sh1.Range(plgOrig).Value
        rw2 = sh2.Cells(Rows.Count, 1).End(xlUp).Row + 1
    End If
Next i
sh2.Activate
End Sub

OMG !!!!! Ca marche :):)

Vous m'avez sauvé la vie, un gros merci !

Rechercher des sujets similaires à "comment transposer"