You are here:

Excel/Compounding Formulae

Advertisement


Question
QUESTION: Dear Tom, I consulted you many years ago and you gave me fantastic advise for excel problems hence I am returning with another question.

I am using Excel 2010 and producing a spreadsheet for my good friend to help him evaluate enquiries.

I am using the following formula for identifying substrings in a cell =IF(ISNUMBER(SEARCH("thailand",$cell)),"Yes","") and I wish to check the cell for the following values also "cambodia", "taiwan", "china", "vietnam". I wish to combine the search into one formula so any and all found will return YES. I am having a brain freeze on this and would greatly appreciate your help.

Very best regards

Mike

ANSWER: Mike,
If I understand you want to return yes if any of the five locations are in the range referred to by $cell, then I would use this.


=IF(SUM(COUNTIF(B2,{"thailand","cambodia","taiwan","china","vietnam"}))>0,"Yes","")

--
Regards,
Tom Ogilvy





---------- FOLLOW-UP ----------

QUESTION: Dear Tom

It did not work out for me but I feel it is because I did not clearly state the searched content being in one cell not an array. I will try and show below what I am doing more clearly. I am using an array of 5 cells to return values because of the max 7 arguments with the IF function and in two cells I require 8 arguments. I can send an excel file showing what I require if the following does not explain well enough.

[search value] [asia] [europe1] [europe2] [mid east] latin am1][latin am2]


[search value]
Vietnam_TESOL; Vietnam_TESOL; Vietnam_TESOLPlus; Vietnam_Volunteer; Vietnam_VolPlus; Czech_TESOL; Greece_TESOL; Hungary_TESOL; Florence_TESOL; Russia_TESOL; Barcelona_TESOL; Argentina_TESOL; Brazil_TESOL; Chile_TESOL; CostaRica_TESOL;

[asia]
=IF(OR(ISNUMBER(SEARCH("thailand",$A2)),ISNUMBER(SEARCH("cambodia",$A2)),ISNUMBER(SEARCH("vietnam",$A2)),ISNUMBER(SEARCH("china",$A2)),ISNUMBER(SEARCH("taiwan",$A2))),"Yes","")

[europe 1]
=IF(OR(ISNUMBER(SEARCH("florence",$A2)),ISNUMBER(SEARCH("greece",$A2)),ISNUMBER(SEARCH("barcelona",$A2)),ISNUMBER(SEARCH("italy",$A2)),ISNUMBER(SEARCH("spain",$A2))),"Yes","")

[europe 2]
=IF(OR(ISNUMBER(SEARCH("czech",$A2)),ISNUMBER(SEARCH("russia",$A2)),ISNUMBER(SEARCH("hungary",$A2))),"Yes","")

This works for me but I have to split the europe search into 2 cells because if I have 8 arguments nested under the IF function returns an error. I would like a single cell search to return the result I seek for europe 1 & 2 search. I also have the same problem with Latin america having 8 arguments.

I know I can nest up to 64 IF functions within one cell but not sure how to achieve this.

I hope this clarifies what I am seeking to achieve. I can also send a sample spreadsheet showing exactly what I am trying to do but I neeed you to let me know how to do this.

Best regards

Mike

Answer
Mike,

So yes, I assumed a single value in the cell being examined.  It appears you want to match substrings in that single cell.   I would change each string from  
=IF(SUM(COUNTIF(B2,{"thailand","cambodia","taiwan","china","vietnam"}))>0,"Yes","")
to
=IF(SUM(COUNTIF(B2,{"*thailand*","*cambodia*","*taiwan*","*china*","*Vietnam*"}))>0,"Yes","")

but back to your formulas:
No reason this shouldn't work

[Europe]

=IF(OR(ISNUMBER(SEARCH("florence",$A2)),ISNUMBER(SEARCH("greece",$A2)),ISNUMBER(SEARCH("barcelona",$A2)),ISNUMBER(SEARCH("italy",$A2)),ISNUMBER(SEARCH("spain",$A2)),ISNUMBER(SEARCH("czech",$A2)),ISNUMBER(SEARCH("russia",$A2)),ISNUMBER(SEARCH("hungary",$A2))),"Yes","")

the number of conditions in an OR statement is not nesting.  Your isnumber(search))  is nested, but it is only three deep counting the OR statement.

all that said,  this is the same as the above formula:

=IF(SUM(COUNTIF(A2,{"*florence*","*greece*","*barcelona*","*italy*","*spain*","*czech*","*russia*","*hungary*"}))>0,"Yes","")

and simpler I think.

--
Regards,
Tom Ogilvy  
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

Excel

All Answers


Answers by Expert:


Ask Experts

Volunteer


Tom Ogilvy

Expertise

Selected as an Excel MVP by Microsoft since 1999. Answering Excel questions in Allexperts since its inception in 2001. Able to answer questions on almost all aspects of Excel's internal capabilities. If seeking a VBA solution, please specify that in your question itself so I give you the answer you want. [Excel has weak protection - if you are distributing an application, I don't answer questions on how to protect your project from your users.]

Experience

Extensive experience.

Education/Credentials
Master of Science (MS) degree Operations Research (ORSA)

Awards and Honors
Microsoft MVP in Excel.

©2016 About.com. All rights reserved.