📜  Enlever les doublons d'une ComboBox - 任何代码示例

📅  最后修改于: 2022-03-11 14:55:12.495000             🧑  作者: Mango

代码示例1
Private Sub UserForm_Initialize()
  t = Timer ')
  Set f = Sheets("base_de_donnees")
  Set MonDico = CreateObject("Scripting.Dictionary")
  For Each c In f.Range("a2:B" & f.[a65000].End(xlUp).Row)
    MonDico(UCase(c.Value)) = ""
  Next c
  temp = MonDico.keys
  Call tri(temp, LBound(temp), UBound(temp))
  Me.ComboBox1.List = temp
  MsgBox Timer() - t
End Sub

Sub tri(a, gauc, droi) ' Quick sort
  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