In the following example, I have a list of fruits and vegetables in Column A. Columns D and E have names of few fruits and vegetables. In the column B, I have entered countif formula to see if the object in the column A is a fruit or vegetable. The formula works but in real life I have numerous columns and not just D & E, and I don't know how to write something which will look at each of those columns and then get the answer which will be equal to the first row of the matched column. B will be blank if unmatched. Thank you in advance.
Book2 | |||||||
---|---|---|---|---|---|---|---|
A | B | C | D | E | |||
1 | Vegetable | Fruit | |||||
2 | Carrots | Grapes | |||||
3 | Broccoli | Vegetable | Broccoli | Banana | |||
4 | Orange | Fruit | Spinach | Orange | |||
5 | Spinach | Vegetable | cucumbers | Apple | |||
6 | Apple | Fruit | |||||
7 | |||||||
8 | |||||||
9 | |||||||
10 | |||||||
11 | |||||||
12 | |||||||
13 | |||||||
14 | |||||||
15 | |||||||
Sheet1 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
B3:B6 | B3 | =IF((COUNTIF($D$2:$D$15,$A3)=1),$D$1,IF((COUNTIF($E$2:$E$15,$A3)=1),$E$1,"")) |