Wildcard If Statment

leighmetcalfe

New Member
Joined
Oct 27, 2012
Messages
39
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
Joined
Aug 18, 2011
Messages
6,219
Office Version
365
Platform
Windows
Hi, if you want to test that it stats with 99 you could try:

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

FormR

MrExcel MVP
Joined
Aug 18, 2011
Messages
6,219
Office Version
365
Platform
Windows
Another solutioun might be =IF(BZ1="99*"),"True","False")
Hi, but you can't use wildcards like that in IF() statements, hence the workaround.
 

jtakw

Well-known Member
Joined
Jun 29, 2014
Messages
5,146
Hi,

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

=LEFT(BZ1,2)="99"
 

mole999

Moderator
Joined
Oct 23, 2004
Messages
9,899
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
Joined
Jun 29, 2014
Messages
5,146
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,"")
 

Forum statistics

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

Some videos you may like

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...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top