Private Sub Bc_rechercher_Click()
Dim P As Range, nom$, h&, t, liste(), i&, n&
Set P = [Données!Vols]: nom = UCase(Zt_Saisie) & "*"
h = Application.CountIf(P.Columns(3), nom)
If h Then
t = P.Columns(1).Resize(, 3) 'matrice, plus rapide
ReDim liste(1 To h, 1 To 4)
For i = 1 To UBound(t)
If UCase(t(i, 3)) Like nom Then
n = n + 1
liste(n, 1) = i: liste(n, 2) = t(i, 1)
liste(n, 3) = Format(t(i, 2), "hh:mm"): liste(n, 4) = t(i, 3)
End If
Next
With UserForm2
.ListBox1.List = liste
.Caption = "Vols à destination de " & Left(nom, Len(nom) - 1) & "..."
.Show 0 'non modal
End With
Else
MsgBox Left(nom, Len(nom) - 1) & "... introuvable !", vbCritical, "Erreur"
With Zt_Saisie: .SetFocus: .SelStart = 0: .SelLength = Len(nom): End With
End If
End Sub