简体   繁体   中英

How can I add a wildcard to my if formula (that also contains an or condition)

I have a column of locations on an Excel file, and some of the locations can be named something like this

在此处输入图像描述

So what I want to do with my formula is say, if the last 3 characters are "IDE" or, if the last 5 characters are "IDE-(and a wildcard) then add a "Y" to the column otherwise add an "N".

I have the following formula, but even though the location is MyLocation IDE-1 it is still giving me an "N" and I'm not sure f what I am doing wrong

=IF(OR(RIGHT(L1,3)="IDE", RIGHT(L1,5)="IDE-"&"*"),"Y","N")

Try:

在此处输入图像描述

Formula in B1 :

=IF(SUM(COUNTIF(A1,{"* IDE","* IDE-?"})),"Y","N")

Or, a little less verbose:

=IF(SUM(COUNTIF(A1,"* IDE"&{"","-?"})),"Y","N")
=IF(OR(RIGHT(L1,3)="IDE", IFERROR(SEARCH("IDE-*",RIGHT(L1,5),1),FALSE)),"Y","N")

Change your RIGHT(L1,5)="IDE-"&"*" to IFERROR(SEARCH("IDE-*",RIGHT(L1,5),1),FALSE) . SEARCH can use wildcards

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM