Any way to word search in a Text Box?

  • Thread starter Thread starter lbbss
  • Start date Start date
L

lbbss

I have text info in my excel text box, but I can't do a word search in
the text box. Any ideas. What about inside my cell notes?
 
I have text info in my excel text box, but I can't do a word search in
the text box. Any ideas. What about inside my cell notes?

You could convert the value into string and search using Instr for
e.g.
Can you post smoe code please?
 
maybe a subroutine like this...

Sub FindInTextBox(strFind As String)

Dim s As Shape

For Each s In ActiveSheet.Shapes
If s.Type = msoTextBox Then
If InStr(1, s.OLEFormat.Object.Caption, strFind, vbTextCompare)
MsgBox strFind & " found in " & s.Name
s.Select
Exit For
End If
End If
Next s

End Sub
 
I tried pasting that routine into a vba macro, but it crashed before
the 0> Then line. Not sure how that macro should work. Where would
you input the word you are searching for? tx
 
The newsreader wrapped the code. Make sure the "If" up to the ">0 Then" is
on one line.. This should be on one line:

If InStr(1, s.OLEFormat.Object.Caption, strFind, vbTextCompare) > 0 Then


To use it, you would pass the word you are searching for as a parameter.
For example, to look for "string1":

FindInTextBox "string1"


It will search for "string1" in text boxes in the active sheet.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top