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 |
All times are GMT +1. The time now is 06:07 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com