Hello friends;
I'm using this code to search in Excel Table and display the result in LISTBOX On USERFORM
but I think this code is complex
do you have another code?
Can you suggest an easier code?
I'm using this code to search in Excel Table and display the result in LISTBOX On USERFORM
but I think this code is complex
do you have another code?
Can you suggest an easier code?
Code:
Private Sub TextBox1_Change()
Dim Data, Arr, Crit As String
Crit = TextBox1
With Sheets("Database").ListObjects(1).Range
Data = Filter(Evaluate("Transpose(If((" & .Columns(1).Address & "=""Name"")+(IsNumber(Search(""" & Crit & """," & .Columns(1).Address & "))),row(1:" & .Rows.Count & ")))"), False, 0)
If UBound(Data) > -1 Then Arr = Application.Transpose(Application.Index(.Value, Data, Application.Evaluate("row(1:" & .Columns.Count & ")")))
With Me.ListBox1
.ColumnCount = 2
.ColumnWidths = "270;60"
.List = Arr
End With
End With
End Sub