Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to search on more than one column in excel

Status
Not open for further replies.

jjfjr

Programmer
Mar 10, 2004
13
US
Hi;

I have an excel application of seven textboxes, asubmit button and a reset button on one sheet of a workbook. Another sheet has the data to be searched and another sheet will hold the results.

I can enter info on one textbox and after clicking the submit button the result will appear. My code for each textbox looks like:

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

And it continues for each of the remaining textboxes (textbox3 to textbox7). I want to be able to enter info on more than one textbox and retrieve all unique rows that match the criteria. For example, if I enter "Area1" in the location textbox , "Grumman" in the manufacturer textbox and "left wing" in the item description textbox; I want to get all of the unique rows that conatin these keywords in the respective columns. Any help is gretly appreciated
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top