Bonsoir,
Dim f, choix(), Rng, Ncol
Private Sub UserForm_Initialize()
Set f = Sheets("bd")
Set Rng = f.Range("A3:M" & f.[A65000].End(xlUp).Row)
Tbltmp = Rng.Value
Ncol = Rng.Columns.Count
For i = LBound(Tbltmp) To UBound(Tbltmp)
ReDim Preserve choix(1 To i)
For k = LBound(Tbltmp) To UBound(Tbltmp, 2)
choix(i) = choix(i) & Tbltmp(i, k) & " * "
Next k
Next i
'---listview
With Me.ListView1
With .ColumnHeaders
.Clear
For k = 1 To Ncol
.Add , , f.Cells(2, k), f.Columns(k).Width * 0.9
Next k
End With
.Gridlines = True
.View = lvwReport
ligne = 1
For i = 1 To UBound(Tbltmp)
.ListItems.Add , , Tbltmp(i, 1)
For k = 2 To Ncol
.ListItems(ligne).ListSubItems.Add , , Tbltmp(i, k)
Next k
ligne = ligne + 1
Next i
End With
End Sub
Private Sub TextBox1_Change()
If Me.TextBox1 <> "" Then
mots = Split(Trim(Me.TextBox1), " ")
Tbl = choix
For i = LBound(mots) To UBound(mots)
Tbl = Filter(Tbl, mots(i), True, vbTextCompare)
Next i
If UBound(Tbl) > -1 Then
Me.ListView1.ListItems.Clear
ligne = 1
For i = LBound(Tbl) To UBound(Tbl)
a = Split(Tbl(i), "*")
Me.ListView1.ListItems.Add , , a(0)
For k = 1 To Ncol - 1
Me.ListView1.ListItems(ligne).ListSubItems.Add , , a(k)
Next k
ligne = ligne + 1
Next i
Me.Label1.Caption = UBound(Tbl) + 1
End If
Else
UserForm_Initialize
End If
End Sub
BISSON