Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Search based on TextBox

I have a TextBox which places a name on a worksheet, which is then sorted.
What need to do is have code which will perform a search for the value of
TextBox1. In the search example below TextBox1 value is represented by betty
johnson but of course could be any name


Cells.Find(What:="betty johnson", After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Search based on TextBox

Hi Patrick.

Try:

'=================
Sub Test04()
Dim rng As Range
Dim sStr As String
sStr = ActiveSheet.TextBox1.Value

Set rng = Cells.Find(What:=sStr, _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)

If Not rng Is Nothing Then
'text found, do something, e.eg.:
MsgBox rng.Address
End If

End Sub
'<<=================


---
Regards,
Norman



"Patrick Simonds" wrote in message
...
I have a TextBox which places a name on a worksheet, which is then sorted.
What need to do is have code which will perform a search for the value of
TextBox1. In the search example below TextBox1 value is represented by
betty johnson but of course could be any name


Cells.Find(What:="betty johnson", After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Search based on TextBox

I want to thank you for all your help this evening. Here is the code I got
to work for me:

Cells.Find(What:=Add_New_Member.TextBox3.Text, After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate


"Norman Jones" wrote in message
...
Hi Patrick.

Try:

'=================
Sub Test04()
Dim rng As Range
Dim sStr As String
sStr = ActiveSheet.TextBox1.Value

Set rng = Cells.Find(What:=sStr, _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)

If Not rng Is Nothing Then
'text found, do something, e.eg.:
MsgBox rng.Address
End If

End Sub
'<<=================


---
Regards,
Norman



"Patrick Simonds" wrote in message
...
I have a TextBox which places a name on a worksheet, which is then sorted.
What need to do is have code which will perform a search for the value of
TextBox1. In the search example below TextBox1 value is represented by
betty johnson but of course could be any name


Cells.Find(What:="betty johnson", After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate





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
Calculate Textbox value based on another textbox value.doc Tdungate Excel Discussion (Misc queries) 1 February 12th 09 07:11 PM
Calculate Textbox value based on another textbox value Tdungate Excel Discussion (Misc queries) 0 February 12th 09 07:03 PM
Search Google from Textbox John[_88_] Excel Programming 6 October 13th 05 03:55 PM
How do I do a search and replace in a textbox in Excel? ToolQueen Excel Discussion (Misc queries) 0 June 27th 05 09:25 PM
Textbox - search Greg[_12_] Excel Programming 1 September 20th 03 12:25 AM


All times are GMT +1. The time now is 04:06 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"