Wildcard If Statment

leighmetcalfe

New Member
I'm struggling to use a wildcard with an if statement.

my formula is "=IF(OR(BZ1="99",BZ1="99"&"*"),"True","False")"

I need it to check the cell and if it has either 99 or variations of 99- then be true.

Last edited:

FormR

MrExcel MVP
Hi, if you want to test that it stats with 99 you could try:

=IF(LEFT(BZ1,2)="99","True","False")

leighmetcalfe

Worked Perfect.

Thank you.

New Member
Another solutioun might be =IF(BZ1="99*"),"True","False")

FormR

MrExcel MVP
Another solutioun might be =IF(BZ1="99*"),"True","False")
Hi, but you can't use wildcards like that in IF() statements, hence the workaround.

New Member
Yes, you are right, my mistake

jtakw

Well-known Member
Hi,

Or, if you want to return the Logical TRUE/FALSE rather then the Text "True", "False":

=LEFT(BZ1,2)="99"

mole999

Moderator
I had need of a wild card came up with this > =IF(COUNTIF(S3:S3,"*A/S*"),1,IF(COUNTIF(S3:S3,"*HOSPITAL*"),1,IF(COUNTIF(S3:S3,"*UNKNOWN*"),1,IF(COUNTIF(S3:S3,"*NRECORDE*"),1,""))))

no idea if that is good practice or not, everything else I found was functions

jtakw

Well-known Member
Hi mole999,

I'm making a couple of assumptions here:

1. You're looking in a Single cell (S3 for this sample)
2. You Don't want Partial strings like AA/SS, HOSPITALIZED, NRECORDED, etc. "mis" Counted

If point 2 above is correct, I would add a Space in front and after the Text string to be searched, so that the formula will only result True for those specific words:

=IF(ISNUMBER(LOOKUP(2,1/SEARCH({" A/S "," HOSPITAL "," UNKNOWN "," NRECORDE "}," "&S3&" "))),1,"")

thats far neater

1,082,360
Messages
5,364,920
Members
400,815
Latest member
Joaquin Phoenix

This Week's Hot Topics

• populate from drop list with multiple tables
Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
• Find list of words from sheet2 in sheet1 before a comma and extract text vba
Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
• Dynamic Formula entry - VBA code sought
Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...