I'm a newbie at this VBA/Excel stuff, so I hope I don't come across too green.
I am trying to create a filtering system using an input from a textbox that will list results from two columns in a listbox in real time, not using a seperate search command button. The problem I'm having is that the keywords can be used for either column and can only return values associated with a particular cell. what I have is part numbers in one column and their associated description in the other. I would like to use the keyword search tool to allow the user to search either by a part number or a part of the description, and then return both associated cells to the listbox. Sound confusing? Anyway, if you excel gurus could help this greenthumb out that would be great. I found this code on this site, but I can't really understand how to modify it to do what I need.
Private Sub txtbxSEARCH_Change()
Dim Fst As String, cl As Range
lstbxRESULTS.Clear
If txtbxSEARCH.Value<> "" Then
Set cl = Sheets(2).Cells.Find(what:=txtbxSEARCH.Value, _
LookIn:=xlValues, lookat:=xlPart, MatchCase:=False)
If Not cl Is Nothing Then
Fst = cl.Address
Me.lstbxRESULTS.AddItem cl.Value
Do
Set cl = Sheets(2).Cells.FindNext(cl)
If Not cl Is Nothing And cl.Address<> Fst Then _
Me.lstbxRESULTS.AddItem cl.Value
Loop Until cl.Address = Fst
End If
End If
End Sub
_________________
Thanks
Luke
This message was edited by luke w on 2002-10-29 14:21
I am trying to create a filtering system using an input from a textbox that will list results from two columns in a listbox in real time, not using a seperate search command button. The problem I'm having is that the keywords can be used for either column and can only return values associated with a particular cell. what I have is part numbers in one column and their associated description in the other. I would like to use the keyword search tool to allow the user to search either by a part number or a part of the description, and then return both associated cells to the listbox. Sound confusing? Anyway, if you excel gurus could help this greenthumb out that would be great. I found this code on this site, but I can't really understand how to modify it to do what I need.
Private Sub txtbxSEARCH_Change()
Dim Fst As String, cl As Range
lstbxRESULTS.Clear
If txtbxSEARCH.Value<> "" Then
Set cl = Sheets(2).Cells.Find(what:=txtbxSEARCH.Value, _
LookIn:=xlValues, lookat:=xlPart, MatchCase:=False)
If Not cl Is Nothing Then
Fst = cl.Address
Me.lstbxRESULTS.AddItem cl.Value
Do
Set cl = Sheets(2).Cells.FindNext(cl)
If Not cl Is Nothing And cl.Address<> Fst Then _
Me.lstbxRESULTS.AddItem cl.Value
Loop Until cl.Address = Fst
End If
End If
End Sub
_________________
Thanks
Luke
This message was edited by luke w on 2002-10-29 14:21