Wildcards in If Statement

S

Stevkev

It's driving me bonkers. I need to retrieve a true value if the text in a cell contains the word "Rows" plus an * wildcard in an If statement. I am at a loss on what syntax to use to retrieve this value.
 
P

Peo Sjoblom

One way

=IF(ISNUMBER(SEARCH("Rows",A1)),"contains","contains not")

--

Regards,

Peo Sjoblom

Stevkev said:
It's driving me bonkers. I need to retrieve a true value if the text in a
cell contains the word "Rows" plus an * wildcard in an If statement. I am
at a loss on what syntax to use to retrieve this value.
 
D

Dave Peterson

if that rows is followed directly by an asterisk, then a minor change to Peo's
formula:

=IF(ISNUMBER(SEARCH("Rows~*",A1)),"contains","contains not")

or a different formula:
=IF(COUNTIF(A1,"*rows~**")>0,"contains","contains not")

the ~* means to look for the asterisk itself--not any set of characters
(represented by the wild card).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top