1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| Option Explicit
Option Compare Text
Dim Ws As Worksheet
Dim T1
Sub AlimenteListbox()
Dim j As variant, i As variant, Indice As variant, D As variant, T2()
Me.ListBox1.Clear
Indice = 1 ' Par défaut toujours 1 enregistrement
For j = 1 To UBound(T1)
If T1(j, 1) Like Me.textbox1 & "*" And T1(j, 2) Like Me.textbox2 & "*" And T1(j, 3) Like Me.textbox3 & "*" And T1(j, 4) Like Me.textbox4 & "*" Then
Indice = Indice + 1
ReDim Preserve T2(1 To 5, 1 To Indice)
For i = 1 To UBound(T1, 2)
T2(i, Indice) = T1(j, i)
Next i
For D = 1 To UBound(T1, 1)
Next D
End If
Next j
If Indice > 1 Then
Me.ListBox1.List = Application.Transpose(T2)
Me.ListBox1.RemoveItem 0 ' On supprime l'enregistrement par défaut
End If
End Sub
private sub textbox1_Change()
AlimenteListbox
End Sub
private sub textbox2_Change()
AlimenteListbox
End Sub
private sub textbox3_Change()
AlimenteListbox
End Sub
private sub textbox4_Change()
AlimenteListbox
End Sub
Private Sub UserForm_Initialize()
Dim j As Long, Gauche As Double, Temp As String, i As Integer
Dim Mondico As Object
Set Ws = Sheets("feuil4")
T1 = Ws.Range("A2:e" & Ws.Range("A" & Rows.Count).End(xlUp).Row)
For j = 1 To UBound(T1)
T1(j, UBound(T1, 2)) = j + 1
Next j
Gauche = Me.ListBox1.Left + 5
For i = 1 To 5
Next i
With Me.ListBox1
.List = T1
end witch
end sub |
Partager