Re : Frame ou textbox
Bonsoir à tous,
Je me permets de renouveler ma demande postée il y a déjà plusieurs jours. Peut-être que ma demande n’était assez claire.
Malgré mes toutes mes recherches à travers le forum excel-downloads ces derniers jours, Je reviens toujours la même procédure qui répondait bien à mes souhaits. . (ListBoxMultiColIntuitifCombobo). Malheureusement, pour moi je n'arrive à adapter cette procédure à mon projet.
La procédure trouvée est la suivante :
Dim f, bd()
Private Sub UserForm_Initialize()
Set f = Sheets("bd")
bd = f.Range("a2:d" & [a65000].End(xlUp).Row).Value
For i = 1 To UBound(bd, 2)
temp = temp & f.Columns(i).Width * 1.1 & ";"
Me("label" & i) = f.Cells(1, i)
Me("label" & i).Top = Me.ListBox1.Top - 12
largeur = largeur + f.Columns(i).Width * 1.1
Next
Me.ListBox1.ColumnCount = UBound(bd, 2)
Me.ListBox1.ColumnWidths = temp
Me.Width = largeur + 50
Me.ListBox1.List = bd
Set d1 = CreateObject("scripting.dictionary")
For i = 1 To UBound(bd)
If bd(i, 1) <> "" Then d1(bd(i, 1)) = ""
Next i
a = d1.keys
Call tri(a, LBound(a), UBound(a))
Me.ComboBox1.List = a
End Sub
Private Sub ComboBox1_Change()
Set d1 = CreateObject("scripting.dictionary")
clé = UCase(Me.ComboBox1) & "*"
Dim Tbl()
n = 0: ncol = UBound(bd, 2)
For i = LBound(bd) To UBound(bd)
If UCase(bd(i, 1)) Like clé Then
n = n + 1: ReDim Preserve Tbl(1 To ncol, 1 To n)
For k = 1 To ncol: Tbl(k, n) = bd(i, k): Next
If bd(i, 1) <> "" Then d1(bd(i, 1)) = ""
End If
Next i
If n > 0 Then
ReDim Preserve Tbl(1 To ncol, 1 To n + 1)
Me.ListBox1.List = Application.Transpose(Tbl)
Me.ListBox1.RemoveItem n
End If
a = d1.keys
Call tri(a, LBound(a), UBound(a))
Me.ComboBox1.List = a
Me.ComboBox1.DropDown
End Sub
Private Sub ComboBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Set d1 = CreateObject("scripting.dictionary")
For i = 1 To UBound(bd)
If bd(i, 2) <> "" Then d1(bd(i, 1)) = ""
Next i
a = d1.keys
Call tri(a, LBound(a), UBound(a))
Me.ComboBox1.List = a
Me.ComboBox1.DropDown
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
J’ai mis des commentaires dans mon Userform. Ceci en pièce jointe
Pouvez-vous venir en aide?
Merci d’avance
M.D