Transformer liste vers Tab 2 D avec VBA

Bonjour à tous,

Je vous explique mon problème, j'ai un tableau Excel sous la forme

Col1 Col2 Col3

X A 12

X B 52

X C 96

Y A 12

Y B 37

Y C 49

Z A 16

Z B 18

Z C 60

A travers une Macro je voudrais transformer ce tableau sous la forme ci dessous et sans utiliser les TCD

A B C

X 12 52 96

Y 9 37 49

Z 16 18 60

Je vous remercie d'avance pour votre aide

bonjour,

une proposition

Sub aargh()
    With Sheets("sheet1") 'à adapter
        dl = .Cells(Rows.Count, 1).End(xlUp).Row
        Set dictcol = CreateObject("scripting.dictionary")
        Set dictlig = CreateObject("scripting.dictionary")
        Set Base = Sheets("sheet1").Range("E1") ' à adapter positionnement du tableau reconstitué

        For i = 2 To dl
            cellig = .Cells(i, 1)
            celcol = .Cells(i, 2)
            celval = .Cells(i, 3)
            If dictlig.exists(cellig) Then
                lig = dictlig(cellig)
            Else
                nligne = nligne + 1
                Base.Cells(nligne + 1, 1) = cellig
                dictlig(cellig) = nligne
                lig = nligne
            End If
            If dictcol.exists(celcol) Then
                col = dictcol(celcol)
            Else
                ncol = ncol + 1
                Base.Cells(1, ncol + 1) = celcol
                dictcol(celcol) = ncol
                col = ncol
            End If
            Base.Cells(lig + 1, col + 1) = celval
        Next i
    End With

End Sub
Rechercher des sujets similaires à "transformer liste tab vba"