A
abu abdullah........halsaeed85
I Have This Code To Run Search By User Form With Textbox To Enter
Search Text Then Return Result On 6 Columns Listbox , Code Working Ok
BuT Sometimes If Too Much Data It Takes A Long Time , If Can Be Beter
Code I will Be Very Grateful .
thanks
Private Sub TextBox1_Change()
On Error Resume Next
Dim KH_Range As Range
Dim M As String
Set KH_Range = Range("ITEMS_INFO")
M = TextBox1.Text
ListBox1.Clear
If M = "" Then GoTo 1
W = ListBox1.ListCount
With KH_Range
KH_1 = .Rows.Count
KH_2 = .Columns.Count
Set A = Range(.Cells(1, 1), .Cells
(.Rows.Count, .Columns.Count)).Find(M)
If Not A Is Nothing Then
F = A.Address
Do
ListBox1.AddItem
ListBox1.List(W, 0) = Sheet2.Cells(A.Row, 1).Value
ListBox1.List(W, 1) = Sheet2.Cells(A.Row, 2).Value
ListBox1.List(W, 2) = Sheet2.Cells(A.Row, 3).Value
ListBox1.List(W, 3) = Sheet2.Cells(A.Row, 4).Value
ListBox1.List(W, 4) = Sheet2.Cells(A.Row, 5).Value
ListBox1.List(W, 5) = Sheet2.Cells(A.Row, 6).Value
W = W + 1
Set A = Range(.Cells(1, 1), .Cells(KH_1, KH_2)).FindNext(A)
Loop While Not A Is Nothing And A.Address <> F
End If
End With
Set A = Nothing
1 End Sub
Search Text Then Return Result On 6 Columns Listbox , Code Working Ok
BuT Sometimes If Too Much Data It Takes A Long Time , If Can Be Beter
Code I will Be Very Grateful .
thanks
Private Sub TextBox1_Change()
On Error Resume Next
Dim KH_Range As Range
Dim M As String
Set KH_Range = Range("ITEMS_INFO")
M = TextBox1.Text
ListBox1.Clear
If M = "" Then GoTo 1
W = ListBox1.ListCount
With KH_Range
KH_1 = .Rows.Count
KH_2 = .Columns.Count
Set A = Range(.Cells(1, 1), .Cells
(.Rows.Count, .Columns.Count)).Find(M)
If Not A Is Nothing Then
F = A.Address
Do
ListBox1.AddItem
ListBox1.List(W, 0) = Sheet2.Cells(A.Row, 1).Value
ListBox1.List(W, 1) = Sheet2.Cells(A.Row, 2).Value
ListBox1.List(W, 2) = Sheet2.Cells(A.Row, 3).Value
ListBox1.List(W, 3) = Sheet2.Cells(A.Row, 4).Value
ListBox1.List(W, 4) = Sheet2.Cells(A.Row, 5).Value
ListBox1.List(W, 5) = Sheet2.Cells(A.Row, 6).Value
W = W + 1
Set A = Range(.Cells(1, 1), .Cells(KH_1, KH_2)).FindNext(A)
Loop While Not A Is Nothing And A.Address <> F
End If
End With
Set A = Nothing
1 End Sub