vendredi 14 juillet 2017

Determine Range in SEARCH function according to condition in Excel

Summary:

I want to verify if a certain word is in a range of cells which should be defined by a criteria. Subsequently I would like to attribute the value of 1 or 0 depending on the existence of that word in the range.

Explanation:

I have a table where I have a list of countries and a list of foreign and domestic clients. An example would be this:

enter image description here

I then have another table where I want to attribute the number 1 or 0, depending on any entry for every country having any foreign client. If the country has any foreign entry then it should be attributed a 1, if otherwise it should be attributed a 0. In this table there is only one entry per country as follows:

enter image description here

In this example, the second table should be populated with a 1 for Algeria, a 0 for Angola and a 1 for Benin as only Algeria and Benin have at least one foreign client.

I have tried combining an IF formula with an ISNUMBER and a SEARCH. However, inside the SEARCH I cannot seem to define the range in which the word should be looked for depending on the country I am analyzing. Basically, what I would like Excel to do is:

1 - Check which country it is analyzing in the second table;

2 - Go to the first table and look for all entries relative to that country;

3 - Check if any of those entries has the word "foreign";

4 - Go back to the second table and attribute a 1 or a 0 for each country, depending on having found the word "foreign in any entry for that country on the first table.

How can I do this? Thank you!

Aucun commentaire:

Enregistrer un commentaire