Dim f, Rng, TblBD(), NbCol, Choix1()
Option Compare Text
Private Sub UserForm_Initialize()
Set f = Sheets("BD")
Set Rng = f.[A1].CurrentRegion.Offset(1)
TblBD = f.[A1].CurrentRegion.Offset(1).Value
NbCol = UBound(TblBD, 2)
Choix1 = ListeMotsTab(f.[A1].CurrentRegion.Offset(1))
For i = 1 To 5
Me("combobox" & i).List = Choix1
Next i
End Sub
Private Sub b_ok_Click()
ReDim Tbl(1 To UBound(TblBD), 1 To NbCol)
n = 0: Dim clé(1 To 5)
For m = 1 To 5: clé(m) = "*" & Me("combobox" & m) & "*": Next m
For i = 1 To UBound(TblBD)
témoin = False
For m = 1 To 5
For k = 1 To NbCol
If clé(m) <> "**" Then If TblBD(i, k) Like clé(m) Then témoin = True: Exit For
Next k
If témoin Then Exit For
Next m
If témoin Then n = n + 1: For k = 1 To NbCol: Tbl(n, k) = TblBD(i, k): Next k
Next i
If n > 0 Then
Set f2 = Sheets("extrait")
f2.Cells.ClearContents
f.Range("A1").CurrentRegion.Resize(1, NbCol).Copy f2.[A1]
f2.[A2].Resize(n, NbCol) = Tbl
f2.Cells(1, NbCol + 5) = "Mots-clés"
For i = 1 To 5: f2.Cells(i + 1, NbCol + 5) = Me("combobox" & i): Next i
Me.ListBox1.ColumnCount = NbCol
EnteteListBox
Me.ListBox1.List = f2.[A1].CurrentRegion.Offset(1).Value
End If
End Sub