Bonjour Forum,
svp pourquoi l' UserForm1 ne fonctionne pas?
voici le code:
Private Sub TextBox1_AfterUpdate()
Dim colhead As Integer
Dim findval As Variant
Dim lastrow As Long
Dim findrow As Long
Dim listcol As Integer
Dim ListRow As Long
Dim i As Long
With Me.ListBox1
' Vider la ListBox avant de la remplir à nouveau
.Clear
For colhead = 1 To 6
.AddItem Sheet1.Cells(1, colhead).Value
Next colhead
ListRow = 0 ' Remettre la valeur de ListRow à 0
If IsDate(Me.TextBox1) Then
findval = CDate(Me.TextBox1.Value)
ElseIf IsNumeric(Me.TextBox1) Then
findval = Val(Me.TextBox1)
Else
findval = "*" & Me.TextBox1 & "*"
End If
lastrow = Sheet1.Range("a" & Rows.Count).End(xlUp).Row
For i = 2 To lastrow
findrow = Application.WorksheetFunction.CountIf(Sheet1.Rows(i).EntireRow, findval)
If findrow > 0 Then
ListRow = ListRow + 1
.AddItem
For listcol = 1 To 6
.List(ListRow, listcol - 1) = Sheet1.Cells(i, listcol).Value
Next listcol
End If
Next i
End With
End Sub