1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| Private Sub TextBox1_Change()
On Error Resume Next
Dim V As Integer, Lastrow As Integer
Dim M As String
Dim Q, F
ListBox1.ColumnWidths = "50pt"
ListBox1.Clear
If TextBox1.Text = "" Then
Else
M = TextBox1.Value
With Sheet2
Lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
Set Q = .Range("A6:A" & Lastrow).Find(M)
If Not Q Is Nothing Then
F = Q.Address
Do
If Application.WorksheetFunction.Search(M, Q, 1) = 1 Then
ListBox1.AddItem Q.Value
ListBox1.List(V, 0) = Q.Offset(0, 0).Value
ListBox1.List(V, 1) = Q.Offset(0, 1).Value
ListBox1.List(V, 2) = Q.Offset(0, 2).Value
ListBox1.List(V, 3) = Q.Offset(0, 3).Value
ListBox1.List(V, 4) = Q.Offset(0, 4).Value
ListBox1.List(V, 5) = Q.Offset(0, 5).Value
ListBox1.List(V, 6) = Q.Offset(0, 6).Value
ListBox1.List(V, 7) = Q.Offset(0, 7).Value
ListBox1.List(V, 8) = Q.Offset(0, 8).Value
ListBox1.List(V, 9) = Q.Offset(0, 9).Value
ListBox1.List(V, 11) = Q.Offset(0, 11).Value
ListBox1.List(V, 13) = Q.Offset(0, 13).Value
ListBox1.List(V, 14) = Q.Offset(0, 14).Value
V = V + 1
End If
Set Q = .Range("A6:A" & Lastrow).FindNext(Q)
Loop While Not Q Is Nothing And Q.Address <> F
End If
End With
End If
End Sub |