View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.misc
T. Valko T. Valko is offline
external usenet poster
 
Posts: 15,768
Default How to search for text?

It depends on what you're searching for any what the strings look like.

A1 = Snapple (22)

=COUNT(SEARCH("apple",A1))0 = TRUE

=COUNT(SEARCH(" apple "," "&A1&" "))0 = FALSE

In the second example we're looking for the *explicit* word "apple". We do
that by "padding" each end of the word with spaces and concatenating each
end of the string with spaces. However, this can also fail if special
characters might be present. Like this:

A1 = Apple, (22)

=COUNT(SEARCH(" apple "," "&A1&" "))0 = FALSE

So, it all depends on what you're looking for and what the strings look
like.

A regular expression UDF might be needed when special characters are present
but I'm not very familiar with regex. Ron Rosenfeld is the resident expert
on regex.


--
Biff
Microsoft Excel MVP


"Eric" wrote in message
...
For fuzzy matching, the countif function is working when the source file
is
open, such as
=COUNTIF('[Source.xls]sheet'!A1,"apple*")0
but, the countif function is not working when the source file is closed,
it returns #VALUE!

I have tried the function search and find, both functions are working when
the source file is closed, but it seems to me that both do not work for
fuzzy
matching.
Does anyone have any suggestions?
Thank everyone very much for any suggestions
Eric

"T. Valko" wrote:

One mo

=COUNTIF(A1,"*apple*")0

NB: this type of fuzzy matching is vulnerable to false positives. For
example, the above will match candyapple or Snapple.


--
Biff
Microsoft Excel MVP


"Eric" wrote in message
...
Does anyone have any suggestions on how to search for text?
For example, Apple (93) in cell A1,
I would like to search for any text including Apple in cell A1,
It should return True in cell B1, because the text Apple is included in
cell
A1.
Does anyone have any suggestions?
Thank you very much
Eric