Private Sub TextBox1_Change()
Dim x$, y$, t, ncol%, i&, a(), j%, n&
x = TextBox1: y = TextBox14
t = Sheets("bd").[A1].CurrentRegion
ncol = UBound(t, 2)
For i = 2 To UBound(t)
If t(i, 2) <> "" And LCase(t(i, 2)) Like LCase(x) & "*" _
And t(i, 14) Like "*" & y & "*" Then
n = n + 1
ReDim Preserve a(1 To ncol, 1 To n)
For j = 1 To ncol
a(j, n) = t(i, j)
Next
End If
Next
If n = 0 Then ListBox1.Clear: Exit Sub
ReDim Preserve a(1 To ncol, 1 To n + 1) 'au moins 2 lignes
ListBox1.List = Application.Transpose(a)
ListBox1.RemoveItem n
End Sub
Private Sub TextBox14_Change()
TextBox1_Change
End Sub
Private Sub UserForm_Initialize()
Dim cw$
cw = "30;60;50;90;50;50;70;50;50;50;50;50;50;50;50" 'largeurs à adapter
ListBox1.ColumnWidths = cw
ListBox1.Width = Evaluate("SUM({" & cw & "})") + 4
Me.Width = ListBox1.Width + 18
TextBox1_Change
End Sub
Option Explicit
Dim WithEvents CL As ComboBoxLiées
Dim TLgn() As Long
'
Private Sub UserForm_Initialize()
Dim cw$
cw = "30;60;50;90;50;50;70;50;50;50;50;50;50;50;50" 'largeurs à adapter
ListBox1.ColumnWidths = cw
ListBox1.Width = Evaluate("SUM({" & cw & "})") + 4
Me.Width = ListBox1.Width + 24
Set CL = New ComboBoxLiées
CL.Plage Feuil1.Rows(2)
CL.Add Me.CBxNom, "B"
CL.Add Me.CBxDate, "N"
CL.Actualiser
End Sub
'
Private Sub CL_Change(ByVal Complet As Boolean, ByVal NbrLgn As Long)
If NbrLgn = 0 Then ListBox1.Clear
End Sub
'
Private Sub CL_Résultat(Lignes() As Long)
Dim Te(), Le&, Ts(), Ls&, C&
TLgn = Lignes
Te = CL.PlgTablo.Resize(, 15).Value
ReDim Ts(1 To UBound(TLgn), 1 To 15)
For Ls = 1 To UBound(TLgn)
Le = TLgn(Ls): For C = 1 To 15: Ts(Ls, C) = Te(Le, C): Next C, Ls
ListBox1.List = Ts
End Sub
Private Sub TextBox1_Change()
Dim t, x$, y$, f$
t = Timer
x = TextBox1: y = TextBox2
If x = "" And y = "" Then AfficherTout: Exit Sub
f = "=(LEFT(RC2," & Len(x) & ")=""" & x & """)*FIND(""" & y & """,TEXT(""""&RC14,""jj/mm/aaaa""))"
Application.ScreenUpdating = False
On Error Resume Next
Me.ShowAllData
With Range("A2:O" & Range("A" & Rows.Count).End(xlUp).Row)
.Cells(2, .Columns.Count + 2).FormulaR1C1 = f
.AdvancedFilter xlFilterInPlace, .Cells(1, .Columns.Count + 2).Resize(2)
.Cells(2, .Columns.Count + 2) = ""
End With
'MsgBox "Durée " & Format(Timer - t, "0.00 \s") 'pour tester
End Sub
Private Sub TextBox2_Change()
TextBox1_Change
End Sub
Sub AfficherTout()
Application.EnableEvents = False
On Error Resume Next
Me.ShowAllData
TextBox1 = "": TextBox2 = ""
Application.EnableEvents = True
End Sub