You are on page 1of 5

Gérant Civilité Naissance Salaire Adresse Ville Profession

Yann Mr 12/23/1979 3000 2 rue de parly Paris Electricien


Lauralou Mme 12/13/1945 5000 11,rue des fleurs Issy Informaticien
Pierre Mr 12/1/1978 4000 4, rue de Parly Voisins Plombier
Brigitte Mme 12/13/1945 5000 11,rue des fleurs Paris Peintre
Zoé Mme 12/1/1978 4500 7, rue Nobel Nice Electricien
François Mr 3/21/1946 3000 12,rue des fleurs Nice Informaticien
Françoise Mle 4/12/1980 3000 4, rue de Parly Paris Plombier
Liliane Mle 4/13/1980 3000 11,rue de Nice Issy Peintre
Viviane Mme 4/14/1980 3000 12, rue Nobel Montigny Electricien
Nicolas Mr 4/15/1980 3000 13, rue Nobel Montigny Informaticien
Espinasse Mr 4/16/1980 3000 13, rue Nobel Montigny Plombier
Dampierre Mr 4/17/1980 3000 13, rue Nobel Paris Peintre
Merkel Mme 4/18/1980 2000 12, rue des poètes Berlin Electricien
Ceuzin Mme 4/19/1980 2000 18, rue Escarpit Neuilly Informaticien
Meridon Mr 4/20/1980 2000 11,rue des fleurs Paris Plombier
Marmotte Mr 4/21/1980 2000 4, rue de Parly Paris Peintre
Durand Mr 4/20/1970 3800 11, rue Nobel Paris Plombier
Recherche multi-colonnes multi-mots
http://boisgontierjacques.free.fr les mots peuvent être saisis dans un ordre quelconque
Dim f, choix(), Rng, Ncol
Private Sub UserForm_Initialize()
Set f = Sheets("bd")
Set Rng = f.Range("A3:G" & f.[a65000].End(xlUp).Row)
Ncol = Rng.Columns.Count
'---- entêtes ListBox
x = 15
Y = Me.ListBox1.Top - 12
For I = 1 To Ncol
Set Lab = Me.Controls.Add("Forms.Label.1")
Lab.Caption = f.Cells(2, I)
Lab.Top = Y
Lab.Left = x + 2
x = x + f.Columns(I).Width * 0.8
temp = temp & f.Columns(I).Width * 0.8 & ";"
Next
Me.ListBox1.ColumnCount = Ncol
Me.ListBox1.ColumnWidths = temp
'-- entêtes TextBox
For I = 1 To Ncol
Set Lab = Me.Controls.Add("Forms.Label.1")
Lab.Caption = f.Cells(2, I)
Lab.Top = Me("textbox" & I + 1).Top - 17
Lab.Left = Me("textbox" & I + 1).Left
x = x + f.Columns(I).Width * 0.5
Next
'--
TblTmp = Rng.Value
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
Me.ListBox1.List = Rng.Value
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
Dim b(): ReDim b(1 To UBound(Tbl) + 1, 1 To Ncol)
For i = LBound(Tbl) To UBound(Tbl)
a = Split(Tbl(i), "*")
For k = 1 To Ncol: b(i + 1, k) = a(k - 1): Next k
Next i
Me.ListBox1.List = b
Me.Label1.Caption = UBound(Tbl) + 1
End If
Else
UserForm_Initialize
End If
End Sub

Private Sub ListBox1_Click()


For k = 0 To Ncol - 1
Me("TextBox" & k + 2) = Me.ListBox1.Column(k)
Next k
End Sub

You might also like