Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default 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
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
VBA code to searching for a folder Farhad Excel Discussion (Misc queries) 2 September 19th 07 02:47 PM
searching by number or code ina work book justsomeguy Excel Discussion (Misc queries) 0 February 19th 07 08:55 PM
Using VBA code when searching in a spreadsheet anb001[_8_] Excel Programming 3 June 29th 04 09:10 AM
Searching range for value (code written but needs 'tweaking'!) ian123[_26_] Excel Programming 8 December 23rd 03 05:19 PM
Searching for VB Code to Link to Program PM_24_7 Excel Programming 0 November 18th 03 05:20 PM


All times are GMT +1. The time now is 08:24 AM.

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

About Us

"It's about Microsoft Excel"