Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Lenny
 
Posts: n/a
Default How do I use a wildcard in an if statement?

I want to use a conditional statement to see if a particular cell has a
specific text within a cell. For example:
I want to know if cell A1 contains the text "bag" even though it actually
contains "Large BAG 3".

I want this to work but it does not:
if(A1="*bag*","yes","no")
It should return "yes" since bag is within the cell.
Please help.
  #2   Report Post  
tjtjjtjt
 
Posts: n/a
Default

You could use:
=IF(ISERROR((FIND("Bag",A1,1))),"no","yes")
But keep in mind that FIND is case sensitive.

You could also use:
=IF(ISERROR((SEARCH("*Bag*",A1,1))),"no","yes")
This would avoid case sensitivity.

tj


"Lenny" wrote:

I want to use a conditional statement to see if a particular cell has a
specific text within a cell. For example:
I want to know if cell A1 contains the text "bag" even though it actually
contains "Large BAG 3".

I want this to work but it does not:
if(A1="*bag*","yes","no")
It should return "yes" since bag is within the cell.
Please help.

  #3   Report Post  
tjtjjtjt
 
Posts: n/a
Default

I put unnecessary parentheses in those formulas. They work just fine like this:

=IF(ISERROR(FIND("Bag",A1,1)),"no","yes")
=IF(ISERROR(SEARCH("*Bag*",A1,1)),"no","yes")

tj

"tjtjjtjt" wrote:

You could use:
=IF(ISERROR((FIND("Bag",A1,1))),"no","yes")
But keep in mind that FIND is case sensitive.

You could also use:
=IF(ISERROR((SEARCH("*Bag*",A1,1))),"no","yes")
This would avoid case sensitivity.

tj


"Lenny" wrote:

I want to use a conditional statement to see if a particular cell has a
specific text within a cell. For example:
I want to know if cell A1 contains the text "bag" even though it actually
contains "Large BAG 3".

I want this to work but it does not:
if(A1="*bag*","yes","no")
It should return "yes" since bag is within the cell.
Please help.

  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default

I don't think tj wanted to add the asterisks to the second example. (It makes
it kind of look like they're required for =Search(), and not required for
=find().)

=IF(ISERROR((SEARCH("Bag",A1,1))),"no","yes")

(but they didn't hurt either.)

I betting that tj was playing with posting this alternative:
=IF(COUNTIF(A1,"*bag*")=0,"no","yes")


tjtjjtjt wrote:

You could use:
=IF(ISERROR((FIND("Bag",A1,1))),"no","yes")
But keep in mind that FIND is case sensitive.

You could also use:
=IF(ISERROR((SEARCH("*Bag*",A1,1))),"no","yes")
This would avoid case sensitivity.

tj

"Lenny" wrote:

I want to use a conditional statement to see if a particular cell has a
specific text within a cell. For example:
I want to know if cell A1 contains the text "bag" even though it actually
contains "Large BAG 3".

I want this to work but it does not:
if(A1="*bag*","yes","no")
It should return "yes" since bag is within the cell.
Please help.


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wildcard Not Working in IF statement [email protected] Excel Worksheet Functions 6 January 9th 05 07:49 AM
7+ nested if statement? Turi Excel Worksheet Functions 3 December 20th 04 07:55 PM
Statement lintan Excel Worksheet Functions 1 December 2nd 04 11:31 PM
Duplicate fields does not match up! If statement Patsy Excel Worksheet Functions 0 November 11th 04 12:16 AM
IF Statement difficulty susan hayes Excel Worksheet Functions 3 November 2nd 04 09:46 PM


All times are GMT +1. The time now is 11:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"