Vậy bạn thiết kế 1 Textbox1, 1 CommandButton1, 1 ListBox. Đoạn code cho CommandButton như sau:
Private Sub CommandButton1_Click()
Dim Cll As Range
Dim i As Long, j As Long
Dim FindCll(0 To 30000) As Variant
ListBox1.Clear
If TextBox1.Value <> "" Then
i = 0
For Each Cll In ActiveSheet.UsedRange
If InStr(1, LCase(Cll.Value), LCase(TextBox1.Value)) > 0 Then
FindCll(i) = Cll.Address
i = i + 1
End If
Next
If i > 0 Then
For j = 0 To i - 1
ListBox1.AddItem FindCll(j)
Next j
End If
End If
End Sub
----
đoạn code cho listbox như sau:
Private Sub ListBox1_Click()
Dim i As Long
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
Range(ListBox1.List(i)).Select
If Range(ListBox1.List(i)).Row > 6 Then
ActiveWindow.ScrollRow = Range(ListBox1.List(i)).Row - 6
Else
ActiveWindow.ScrollRow = 1
End If
End If
Next i
End Sub
---- Sau khi search, bấm vào 1 dòng nào đó của listbox, sẽ tự động chạy đến Cell chứa kết quả tìm kiếm.