Find string within a text in VBA

  • Thread starter Thread starter neta
  • Start date Start date
N

neta

HI,

How can I find a specific string in a text within a VBA code. Fo
example - to search "Japan" in "the capital of Japan is Tokyo" an
receive "TRUE" if found and "FALSE" if not..

Thanks
 
One way:

Dim bFound As Boolean
bFound = InStr("the capital of Japan is Tokyo","Japan") > 0
 
Hi
use InStr for this. e.g.
If InStr(range("A1").value,"Japan")>0 then
msgbox "Found it"
end if
 
Hi Neta!

One way:

=NOT(ISERROR(FIND(" Japan ",A1)))

Note that I've put a space either end of the word sought so as to
avoid TRUE for Japanese.

If you have a series of similar requests you could use:

Put the Country in F1 and then use:

=NOT(ISERROR(FIND(" "&F1&" ",A1)))
 
Norman,

Thanks, could never have guessed.
Now, don't get mad at me, what the heck is "Strine expression"?

Jack.
 
Back
Top