Dim x As Long, i As Long, j As Long, k As Long
Private Sub CommandButton4_Click()
Unload Me: [a1].Select
End Sub
Private Sub CommandButton5_Click()
t = Range("a2:h" & Range("a65536").End(xlUp).Row)
ListBox1.List = t
End Sub
Private Sub reset_Click()
Unload Me: UserForm2.Show
End Sub
Private Sub Textbox1_Change()
On Error Resume Next
Application.ScreenUpdating = False
t = Range("a2:c" & Range("a65536").End(xlUp).Row)
ListBox1.Clear
x = 1
For i = 1 To UBound(t)
For j = 1 To 3
If Left(t(i, j), Len(TextBox1)) = Left(TextBox1, Len(TextBox1)) Then
ReDim Preserve ta(1 To 3, 1 To x)
For k = 1 To 3
ta(k, x) = t(i, k)
Next k: x = x + 1: End If: Next j: Next i
ListBox1.List = Application.Transpose(ta)
Erase t, ta
If TextBox1 = "" Then ListBox1.Clear
Beep
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then Cancel = True
End Sub
' Recherche par la listboxt
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim ListIndex As Integer
For ListIndex = 0 To (ListBox1.ListCount - 1)
If ListBox1.Selected(ListIndex) = True Then
Me.TextBox2 = Me.ListBox1.List(ListIndex, 0) ' Ref
Me.TextBox3 = Me.ListBox1.List(ListIndex, 1) ' Date
Me.TextBox4 = Me.ListBox1.List(ListIndex, 2) ' N° Facture
Exit Sub
End If
Next
End Sub