# Excel question: Does substring exist

**URL:** <https://boards.straightdope.com/t/excel-question-does-substring-exist/220785>\
**Category:** Factual Questions\
**Created:** [December 24, 2003, 4:23am UTC](https://boards.straightdope.com/t/excel-question-does-substring-exist/220785 "2003-12-24T04:23:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![obfusciatrist](https://avatars.discourse-cdn.com/v4/letter/o/4af34b/32.png) [@obfusciatrist](https://boards.straightdope.com/u/obfusciatrist)\
**Post date:** [December 24, 2003, 4:23am UTC](https://boards.straightdope.com/t/excel-question-does-substring-exist/220785/1 "2003-12-24T04:23:04Z")

</div>

I need a formula to use in Excel that will simply return TRUE if a certain subset exists within the text of a cell.

Say for example that cell A1 reads “BLAH BLAH BLAH” and I wanted to find out whether the string “AH BL” exists in that cell.

Is there a way to do that? FIND and SEARCH tell you where the string starts, but it assumes the substring has to be in the referenced cell and returns an error if it isn’t present. So, I either I need a formula to directly test it or some way of usefully using the error.

Anybody know of anything?

---

<div class="post-metadata">

**Author:** ![CookingWithGas](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/cookingwithgas/32/485_2.png) [@CookingWithGas](https://boards.straightdope.com/u/CookingWithGas)\
**Post date:** [December 24, 2003, 4:26am UTC](https://boards.straightdope.com/t/excel-question-does-substring-exist/220785/2 "2003-12-24T04:26:16Z")

</div>

Yes. See Excel Help for the FIND function. The within\_text can be a cell reference.

> [@](#):
>
> FIND(find\_text,within\_text,start\_num)
> 
> FINDB(find\_text,within\_text,start\_num)
> 
> Find\_text is the text you want to find.
> 
> If find\_text is “” (empty text), FIND matches the first character in the search string (that is, the character numbered start\_num or 1).  
> Find\_text cannot contain any wildcard characters.  
> Within\_text is the text containing the text you want to find.
> 
> Start\_num specifies the character at which to start the search. The first character in within\_text is character number 1. If you omit start\_num, it is assumed to be 1.
> 
> Tip Use start\_num to skip a specified number of characters. For example, suppose you are working with the text string “AYF0093.YoungMensApparel”. To find the number of the first “Y” in the descriptive part of the text string, set start\_num equal to 8 so that the serial-number portion of the text is not searched. FIND begins with character 8, finds find\_text at the next character, and returns the number 9. FIND always returns the number of characters from the start of within\_text, counting the characters you skip if start\_num is greater than 1.
> 
> Remarks
> 
> If find\_text does not appear in within\_text, FIND and FINDB return the #VALUE! error value.  
> If start\_num is not greater than zero, FIND and FINDB return the #VALUE! error value.  
> If start\_num is greater than the length of within\_text, FIND and FINDB return the #VALUE! error value.
> 
> Examples
> 
> FIND(“M”,“Miriam McGovern”) equals 1
> 
> FIND(“m”,“Miriam McGovern”) equals 6
> 
> FIND(“M”,“Miriam McGovern”,3) equals 8

---

<div class="post-metadata">

**Author:** ![CookingWithGas](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/cookingwithgas/32/485_2.png) [@CookingWithGas](https://boards.straightdope.com/u/CookingWithGas)\
**Post date:** [December 24, 2003, 4:28am UTC](https://boards.straightdope.com/t/excel-question-does-substring-exist/220785/3 "2003-12-24T04:28:03Z")

</div>

Sorry, I didn’t read carefully enough. You want to say,

=if(iserr(find(“looking for this”,“within this”)),FALSE,TRUE)

---

<div class="post-metadata">

**Author:** ![obfusciatrist](https://avatars.discourse-cdn.com/v4/letter/o/4af34b/32.png) [@obfusciatrist](https://boards.straightdope.com/u/obfusciatrist)\
**Post date:** [December 24, 2003, 4:40am UTC](https://boards.straightdope.com/t/excel-question-does-substring-exist/220785/4 "2003-12-24T04:40:05Z")

</div>

iserr is exactly what I was looking for. Thanks CookingWithGas!

I thought I had looked through that section of the functions but I guess I missed it. I was getting pretty frustrated and we all know that induces blindness.

Much appreciated.

---

<div class="post-metadata">

**Author:** ![x1134x](https://avatars.discourse-cdn.com/v4/letter/x/c68b51/32.png) [@x1134x](https://boards.straightdope.com/u/x1134x)\
**Post date:** [July 25, 2012, 11:41pm UTC](https://boards.straightdope.com/t/excel-question-does-substring-exist/220785/5 "2012-07-25T23:41:39Z")

</div>

> [@CookingWithGas](#):
>
> Sorry, I didn’t read carefully enough. You want to say,
> 
> =if(iserr(find(“looking for this”,“within this”)),FALSE,TRUE)

get rid of the quotes for the “within this” if you want to reference a cell

=if(iserr(find(“looking for this”,within this)),FALSE,TRUE)  
[/QUOTE]
