Private Sub UserForm_Initialize()
Dim c As Integer
UF1.LB1.Clear
For c = 1 To Cells(1, 1).End(xlToRight).Column
UF1.LB1.AddItem Cells(1, c).Value
Next c
UF1.LB1.ListIndex = 1
UF1.TB1 = "?"
UF1.TB1.SelStart = 0
UF1.TB1.SelLength = Len(UF1.TB1.Text)
End Sub
Private Sub TB1_Change()
Dim c As Integer
Dim l As Double
Dim n As Integer
Dim vc As String
Dim vs As String
For c = 1 To Cells(1, 1).End(xlToRight).Column
If UF1.LB1.Value = Cells(1, c).Value Then Exit For
Next c
UF1.LB2.Clear
n = 0
UF1.LB3.Caption = "Aucune ligne sélectionnée"
vs = LCase(UF1.TB1.Text)
If UF1.TB1.TextLength < 1 Then Exit Sub
For l = 2 To Cells(65536, c).End(xlUp).Row
If IsNumeric(Cells(l, c)) Then
vc = Str(Cells(l, c))
Else
vc = LCase(Cells(l, c))
End If
If Not InStr(1, vc, vs) = 0 Then
UF1.LB2.AddItem l & " : " & Cells(l, c).Value
n = n + 1
End If
Next l
If n > 0 Then UF1.LB2.ListIndex = 0
If n = 0 Then UF1.LB3.Caption = "Aucune ligne sélectionnée"
If n = 1 Then UF1.LB3.Caption = "Une ligne sélectionnée"
If n > 1 Then UF1.LB3.Caption = n & " lignes sélectionnées"
End Sub
Private Sub TB1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim l As Double
Dim c As Integer
Dim n As Integer
Dim vc As String
Dim vs As String
For c = 1 To Cells(1, 1).End(xlToRight).Column
If UF1.LB1.Value = Cells(1, c).Value Then Exit For
Next c
UF1.LB2.Clear
n = 0
UF1.LB3.Caption = "Aucune ligne sélectionnée"
vs = LCase(UF1.TB1.Text)
If Me.TB1.Value = "?" Then Exit Sub
For l = 2 To Cells(65536, c).End(xlUp).Row
If IsNumeric(Cells(l, c)) Then
vc = Str(Cells(l, c))
Else
vc = LCase(Cells(l, c))
End If
If Not InStr(1, vc, vs) = 0 Then
UF1.LB2.AddItem l & " : " & Cells(l, c).Value
n = n + 1
Rows(l).Interior.ColorIndex = 3
End If
Next l
End Sub
Private Sub LB2_Click()
Cells(Val(Left(UF1.LB2.Value, InStr(1, UF1.LB2.Value, " "))), 2).Select
End Sub
Private Sub UserForm_Click()
Unload UF1
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
ActiveSheet.Rows.Interior.ColorIndex = xlNone
End Sub