[RESOLU] Sans doublon trié suivant 2 colonnes

Ternoise

XLDnaute Occasionnel
Bonjour
Encore besoin de votre aide !

Avec ce code, ma Listbox se remplie des éléments de la colonne H (sans doublon et trié).
J'aimerais ajouter la colonne J à cette liste

J'avais imaginé ceci !!
HTML:
  For Each c In f.Range("H2:H", "J2:J" & f.[A65000].End(xlUp).Row)

Comment faire ?
Merci de votre aide
David

HTML:
Private Sub Charger_Liste1()
  Set f = Sheets("BDPMT")
  Set Mondico = CreateObject("Scripting.Dictionary")
  For Each c In f.Range("H2:H" & f.[A65000].End(xlUp).Row)
    Mondico(c.Value) = ""
  Next c
  temp = Mondico.keys
  Call Tri(temp, LBound(temp), UBound(temp))
  Me.Liste1.List = temp
End Sub

Sub Tri(a, gauc, droi)
  ref = a((gauc + droi) \ 2)
  g = gauc: d = droi
  Do
    Do While a(g) < ref: g = g + 1: Loop
    Do While ref < a(d): d = d - 1: Loop
      If g <= d Then
        temp = a(g): a(g) = a(d): a(d) = temp
        g = g + 1: d = d - 1
      End If
    Loop While g <= d
    If g < droi Then Call Tri(a, g, droi)
    If gauc < d Then Call Tri(a, gauc, d)
End Sub
 
Dernière édition:

laetitia90

XLDnaute Barbatruc
Re : Sans doublon trié suivant 2 colonnes

bonjour tous:):):)

ben tu rajoutes des conditions dans la boucle

'if condition1 AND condition2 AND condition3

and ou or

ps: on pourrait faire une seule boucle

Code:
 Set pl = Application.Union(f.Range("H2:H" & f.[H65000].End(3).Row), f.Range("J2:J" & f.[J65000].End(3).Row))
  Set mondico = CreateObject("Scripting.Dictionary")
  For Each c In pl
  If Not mondico.Exists(c.Value) And c <> "" Then mondico.Add c.Value, c.Value
  Next c
 

Discussions similaires

Statistiques des forums

Discussions
312 321
Messages
2 087 231
Membres
103 497
dernier inscrit
JP9231