LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default searching on more than one field in VB

Hi;

I created an application that allows a user to enter info in a form on one
sheet into one of seven textboxes and search for information in another sheet
with the results appearing in a third sheet. 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
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Searching data in 3 different field bmurlidhar Excel Discussion (Misc queries) 2 October 30th 09 01:59 PM
How to make a field created a part of the Pivot Table Field List? drhell Excel Discussion (Misc queries) 0 January 29th 07 11:13 PM
Searching, matching then searching another list based on the match A.S. Excel Discussion (Misc queries) 1 December 13th 06 05:08 AM
Linked date field in worksheet defaults a blank field as 1/0/1900 AmnNkD Excel Worksheet Functions 2 September 12th 06 05:42 PM
Field searching? wufishmonger Excel Discussion (Misc queries) 3 June 10th 06 11:01 PM


All times are GMT +1. The time now is 08:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"