• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to SEARCH for more than one word/text/phrase?

Eloise T

Active Member
The formula in Column L is searching in Column J for three words, OSS, Swap, and Unit. If ANY of them are in Column J AND Column H = 50, then put 50 in Column L. So far it works for OSS but not Swap or Unit. What is my error in logic? Thanks.

Spreadsheet attached for clarification.

=IF(AND(H2=50,IFERROR(SEARCH({"*OSS*","*Swap*","*Unit*"},J2)>0,0)),50)
 

Attachments

  • Chandoo - multiple search conundrum 2.xlsx
    10 KB · Views: 8
Last edited:
The spreadsheet did not get uploaded, but perhaps this will work (untested). Change your formula to what is shown below:

=IF(AND(H2=50,SUMPRODUCT(IFERROR(SEARCH({"*OSS*","*Swap*","*Unit*"},J2),0))),50)

Using SEARCH with an array will produce an array result, so I am using SUMPRODUCT to produce a single numeric value instead (this also relies on your existing IFERROR to return a zero when there is no match).

The second change is simply removal of the ">0" test and adding a closing parenthesis for SUMPRODUCT. The AND function only needs a boolean (TRUE or FALSE) result, but any value other than zero is considered TRUE.

I hope that helps,
Ken
 
The spreadsheet did not get uploaded, but perhaps this will work (untested). Change your formula to what is shown below:

=IF(AND(H2=50,SUMPRODUCT(IFERROR(SEARCH({"*OSS*","*Swap*","*Unit*"},J2),0))),50)

Using SEARCH with an array will produce an array result, so I am using SUMPRODUCT to produce a single numeric value instead (this also relies on your existing IFERROR to return a zero when there is no match).

The second change is simply removal of the ">0" test and adding a closing parenthesis for SUMPRODUCT. The AND function only needs a boolean (TRUE or FALSE) result, but any value other than zero is considered TRUE.

I hope that helps,
Ken
THANK YOU!
 
Back
Top