On va donc ne pas tenir compte de :
"Une deuxième demande est d’imprimer le contenu de la listView."
Forum > Visual Basic 6et non celle, adéquate puisque tu développes sous VBA/Excel : Langages dérivés > VBA !
Une deuxième demande est d’imprimer le contenu de la listView.
Application.ScreenUpdating = False Set F1 = Sheets("Feuil3") a = F1.Range("A1").CurrentRegion.Value Dim c() ReDim c(1 To UBound(a, 1), 1 To UBound(a, 2)) ligne = 1 Set mondico = CreateObject("Scripting.Dictionary") For i = 1 To UBound(a) temp = a(i, 1) & a(i, 2) If Not mondico.exists(temp) Then mondico.Add temp, "" For k 1 To UBound(a, 2) - 1: c(ligne, k) a(i, k): Next k c(ligne, k) = c(ligne, k) + a(i, k) ligne = ligne + 1 Else p = Application.Match(temp, mondico.keys, 0) col = UBound(a, 2) - 1 c(p, col) = c(p, col) + a(i, col) End If Next Feuil3.[A1].CurrentRegion.ClearContents 'Feuil3.[A1].Resize(mondico.Count, UBound(a, 2)) = c With UserForm1.ListView1 With .ColumnHeaders .Clear .Add , , "Réference", 50, lvwColumnLeft .Add , , "Nom produit", 140, lvwColumnLeft .Add , , "Quantité", 48, lvwColumnLeft .Add , , "Unité ", 53, lvwColumnLeft End With ligne = 1 .View = lvwReport .FullRowSelect = True .Gridlines = True .AllowColumnReorder = True For Each Z In c .ListItems.Add , , Z '.ListItems(ligne).ListSubItems.Add , , Z.Offset(, 1) '.ListItems(ligne).ListSubItems.Add , , Z.Offset(, 3) '.ListItems(ligne).ListSubItems.Add , , Z.Offset(, 2) 'ligne = ligne + 1 Next Z End With
Dim c(1 To 4, 1 To 3) For i = 1 To 4 For j = 1 To 3 c(i, j) = i + j Next Next For i = LBound(c, 1) To UBound(c, 1) For j = LBound(c, 2) To UBound(c, 2) MsgBox "j'ai " & c(i, j) & " en colonne " & j & " de la ligne " & i Next Next
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionApplication.ScreenUpdating = False Set F1 = Sheets("Feuil3") a = F1.Range("A1").CurrentRegion.Value Dim c() ReDim c(1 To UBound(a, 1), 1 To UBound(a, 2)) ligne = 1 Set mondico = CreateObject("Scripting.Dictionary") For i = 1 To UBound(a) temp = a(i, 1) & a(i, 2) If Not mondico.exists(temp) Then mondico.Add temp, "" For k 1 To UBound(a, 2) - 1: c(ligne, k) a(i, k): Next k c(ligne, k) = c(ligne, k) + a(i, k) ligne = ligne + 1 Else p = Application.Match(temp, mondico.keys, 0) col = UBound(a, 2) - 1 c(p, col) = c(p, col) + a(i, col) End If Next Feuil3.[A1].CurrentRegion.ClearContents With UserForm1.ListView1 With .ColumnHeaders .Clear .Add , , "Réference", 50, lvwColumnLeft .Add , , "Nom produit", 140, lvwColumnLeft .Add , , "Quantité", 48, lvwColumnLeft .Add , , "Unité ", 53, lvwColumnLeft End With ligne = 1 .View = lvwReport .FullRowSelect = True .Gridlines = True .AllowColumnReorder = True For i = LBound(c, 1) + 1 To mondico.Count .ListItems.Add , , c(i, 1) .ListItems(.ListItems.Count).ListSubItems.Add , , c(i, 2) .ListItems(.ListItems.Count).ListSubItems.Add , , c(i, 3) .ListItems(.ListItems.Count).ListSubItems.Add , , c(i, 4) Next End With