Text within a Cell
See, this is what happens when I answer questions before having my morning
cup of coffee... my original test "=1" is fine to use (and, hence, my
original formulas are fine to use as well)... multiple occurrences of "PDQ"
in a **single** cell are only counted once with the COUNTIF function call I
posted. The need for "0" would come in if we were testing *multiple* cells
for the occurrence of that text... since we are only testing a *single*
cell, that COUNTIF function call can only return 0 or 1.
--
Rick (MVP - Excel)
"Rick Rothstein" wrote in message
...
I see Dave posted a COUNTIF method as well; however, his "0" test is
better than my "=1" test (just in case the "PDQ" text appears more than
once in the cell), so I would use that instead...
=LEFT("1",COUNTIF(A1,"*PDQ*")0)
or
=--(COUNTIF(A1,"*PDQ*")0)
depending on what you want to happen, as I posted in my original message,
if "PDQ" is not in the text.
--
Rick (MVP - Excel)
"Rick Rothstein" wrote in message
...
For a formula version, try this...
=LEFT("1",COUNTIF(A1,"*PDQ*")=1)
The above returns 1 if the text is in the cell and the empty string
otherwise. If you wouldn't mind a 0 being returned if the text is not in
the cell, then the above can be shortened to this...
=--(COUNTIF(A1,"*PDQ*")=1)
--
Rick (MVP - Excel)
"N1KO" wrote in message
...
Hi,
I could do with either some VBA code or excel formula to find a
selection of
letters (Eg. PDQ) within a cell.
The letters could be anywhere in the cell and can be of any format Eg
PdQ.
I need it to return a value of 1
Cheers
|