Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
searching on more than one column in VB code
Hi;
I created an application that allows the user to input information into one of seven textboxs. The code for each textbox looks like this: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
VBA code to searching for a folder | Excel Discussion (Misc queries) | |||
searching by number or code ina work book | Excel Discussion (Misc queries) | |||
Using VBA code when searching in a spreadsheet | Excel Programming | |||
Searching range for value (code written but needs 'tweaking'!) | Excel Programming | |||
Searching for VB Code to Link to Program | Excel Programming |