Hello all,
Im busy with a program to search through data and display it in a listbox.
What i've got now;
I can search in the textbox under Find product on boxnr and productname.
What i want to be added is an option to search only on box, or on product name, or year.
I got some code but that doesn't work. I even have problems with showing the column year in the listbox.
Can someone help me with this and explain it a bit so i can add even more in the future?
Code that works but where i need to include 1 more column:
I don't have an option to add files?
Im busy with a program to search through data and display it in a listbox.
What i've got now;
I can search in the textbox under Find product on boxnr and productname.
What i want to be added is an option to search only on box, or on product name, or year.
I got some code but that doesn't work. I even have problems with showing the column year in the listbox.
Can someone help me with this and explain it a bit so i can add even more in the future?
Code that works but where i need to include 1 more column:
Code:
Private Sub txtKeywords_Change() Dim cl As Range
Dim i As Long
Dim ZoekIn As String
Dim wrd() As String
lstSearchResults.Clear
For Each cl In Sheets("sheet1").Range("B2:B" & Range("B2").CurrentRegion.Rows.Count)
ZoekIn = cl.Offset(, -1) & vbTab & LCase(cl.Value)
If InStr(1, ZoekIn, LCase(txtKeywords.Text)) > 0 Then
ReDim Preserve wrd(i)
wrd(i) = ZoekIn
i = i + 1
End If
Next cl
On Local Error GoTo Einde
lstSearchResults.List = wrd
Einde:
End Sub
Private Sub UserForm_Initialize()
Dim cl As Range
Dim i As Long
Dim wrd() As String
For Each cl In Sheets("sheet1").Range("B2:B" & Range("B2").CurrentRegion.Rows.Count)
ReDim Preserve wrd(i)
wrd(i) = cl.Offset(, -1) & vbTab & LCase(cl.Value)
i = i + 1
Next cl
On Local Error GoTo Einde
lstSearchResults.List = wrd
Einde:
End Sub
I don't have an option to add files?