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
|