searching on more than one field in VB
- From: "jjfjr" <jjfjr@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 21 Jun 2005 06:27:03 -0700
Hi;
I created an application that allows a user to enter info in a form on one
*** into one of seven textboxes and search for information in another ***
with the results appearing in a third ***. My code for searching (just
showing two textboxs) is as follows:
If TextBox1.Value <> "" Then
strToFind = TextBox1.Value
Set wksToSearch = Sheet2
Set rngToSearch = wksToSearch.Range("F1").EntireColumn
Set wksToPaste = Sheet3
Set rngPaste = wksToPaste.Range("A1")
Set rngFound = rngToSearch.Find(strToFind, , , xlPart)
If Not rngFound Is Nothing Then
strFirstAddress = rngFound.Address
Do
rngFound.EntireRow.Copy rngPaste
Set rngFound = rngToSearch.FindNext(rngFound)
Set rngPaste = rngPaste.Offset(1, 0)
Loop Until rngFound.Address = strFirstAddress
End If
End If
If TextBox2.Value <> "" Then
strToFind = TextBox2.Value
Set wksToSearch = Sheet2
Set rngToSearch = wksToSearch.Range("G1").EntireColumn
Set wksToPaste = Sheet3
Set rngPaste = wksToPaste.Range("A1")
Set rngFound = rngToSearch.Find(strToFind, , , xlPart)
If Not rngFound Is Nothing Then
strFirstAddress = rngFound.Address
Do
rngFound.EntireRow.Copy rngPaste
Set rngFound = rngToSearch.FindNext(rngFound)
Set rngPaste = rngPaste.Offset(1, 0)
Loop Until rngFound.Address = strFirstAddress
End If
End If
Each piece searches a specific column. I'd like to know what code is
neccessary to search in more than one column within the code. Can all seven
columns be searched at the same time?
Any help is greatly appreciated.
--
JJFJR
.
- Follow-Ups:
- Re: searching on more than one field in VB
- From: Tom Ogilvy
- Re: searching on more than one field in VB
- Prev by Date: Re: How to open new instance of excel if excel is already open?
- Next by Date: Re: Combo box control Drop down list moving
- Previous by thread: searching on more than one column in VB code
- Next by thread: Re: searching on more than one field in VB
- Index(es):
Loading