简体   繁体   中英

Excel: Return value if cell contains a certain text

there are 2 cells.

One contains string

"AA BB CC DD"

And the second one

"AABBCCCDD"

I want to make formula that return value "true", when cells contains "BB". If I use find or search formulas, it returns true for all of them. Nevertheless, there's another condition. I want to use this:

=IF(IS.NUMBER(SEARCH(" BB ".....

Search is consisted of 2 main parameter -> what and where. I want to add 2 values into "what". Something like:

If cell contains " BB " or "BeBe" then...

I hope it' clear.

Thanks

You can search for multiple strings by passing array of strings {} and wrapping in AND() :

=AND(ISNUMBER(SEARCH({"AA","BB"},A1)))

Alternatively, you can wrap it in OR() if you need at least one match, not all of them:

=OR(ISNUMBER(SEARCH({"AA","BB"},A1)))

Wrap it in a SUMPRODUCT:

=SUMPRODUCT(1*(ISNUMBER(SEARCH({" BB ","BeBe"},A1))))>0

SEARCH() is not case sensitive so it will return true for "BEBE" If you want case sensitive use FIND:

=SUMPRODUCT(1*(ISNUMBER(FIND({" BB ","BeBe"},A1))))>0

在此处输入图片说明

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