ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   * in IF statement (https://www.excelbanter.com/excel-discussion-misc-queries/76487-%2A-if-statement.html)

Harley

* in IF statement
 
How do I include * in an IF statement? For example, how do I write
=IF(A1="*abc*","in there", "not there") when "abc" is contained anywhere in
the string in cell A1?

TIA

Ron Coderre

* in IF statement
 
Try one of these:

=IF(ISNUMBER(SEARCH("abc",A1)),"in there","not there")
or
=IF(COUNTIF(A1,"*abc*"),"in there","not there")

Does that help?

***********
Regards,
Ron

XL2002, WinXP-Pro


"Harley" wrote:

How do I include * in an IF statement? For example, how do I write
=IF(A1="*abc*","in there", "not there") when "abc" is contained anywhere in
the string in cell A1?

TIA


Dave Peterson

* in IF statement
 
=if(isnumber(search("abc",a1)),"yep","nope")

=search() is case sensitive.
=find() is not.

alternatively:

=if(countif(a1,"*abc*")0, "yep", "nope")

(not case sensitive)

Harley wrote:

How do I include * in an IF statement? For example, how do I write
=IF(A1="*abc*","in there", "not there") when "abc" is contained anywhere in
the string in cell A1?

TIA


--

Dave Peterson

ewan7279

* in IF statement
 
Hi Harley,

Try =IF(ISERROR(FIND("abc",A1,1)),"NOT THERE","THERE")

Ewan

"Harley" wrote:

How do I include * in an IF statement? For example, how do I write
=IF(A1="*abc*","in there", "not there") when "abc" is contained anywhere in
the string in cell A1?

TIA


Dave Peterson

* in IF statement
 
=find() IS case sensitive
=search() IS NOT.

(and =countif() is not case sensitive)

Dohhh.

Dave Peterson wrote:

=if(isnumber(search("abc",a1)),"yep","nope")

=search() is case sensitive.
=find() is not.

alternatively:

=if(countif(a1,"*abc*")0, "yep", "nope")

(not case sensitive)

Harley wrote:

How do I include * in an IF statement? For example, how do I write
=IF(A1="*abc*","in there", "not there") when "abc" is contained anywhere in
the string in cell A1?

TIA


--

Dave Peterson


--

Dave Peterson

Harley

* in IF statement
 
Thank you Ron and Ewan, all the formulas worked.

"ewan7279" wrote:

Hi Harley,

Try =IF(ISERROR(FIND("abc",A1,1)),"NOT THERE","THERE")

Ewan

"Harley" wrote:

How do I include * in an IF statement? For example, how do I write
=IF(A1="*abc*","in there", "not there") when "abc" is contained anywhere in
the string in cell A1?

TIA



All times are GMT +1. The time now is 07:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com