excel - Check if one of multiple values is present in a column -


i have table in excel 2013 has has thousands of records of food items (beef-frozen, beef-chilled, beef-brisket, beef-ribs, chicken-fillet, chicken-whole, fish-skinned, fish-whole, yogurt, lettuce-imported, lettuce-frozen, tomato-fresh,tomato, water, milk,...etc) stored in column a. notice value may contain other content food item name.

i created column b next column a. want column b hold category of food item in column a. example, if a1 has in "beef" or "chicken" or "fish" b1 should equal "meat". if a1 has in "tomato" or "lettuce" or "onion" b1 should equal "vegetable".

what best way achieve it?

assuming have column headers, enter formula in cell b2:

=rept("meat",max(iferror(match({"*beef*","*chicken*","*fish*"},a2,),)))    &    rept("vegetable",max(iferror(match({"*tomato*","*lettuce*","*onion*"},a2,),))) 

this array formula , must confirmed ctrl+shift+enter.

now copy b2 , select b3 down far need , paste.

note: please closely @ big gap in middle of formula. you'll see 2 separate formulas concatenated ampersand. can extend formula in same way adding phrase similar first 2 new category. in fact, add many more categories in fashion.


Comments