Count certain words in a cell, even if they appear more than once

Wad Mabbit

Board Regular
Joined
Mar 31, 2016
Messages
74
Office Version
  1. 2016
Platform
  1. Windows
Hi, I'd like to be able to count the number of certain words in a cell, e.g. in E4 I have Lamb, rice, coffee, coffee.
In L4 (Beverages column) I want to know how many drinks have been had of either: beverage, tea, coffee ovaltine

In L4 I'm using:
=IF(COUNTBLANK([@[Food taken]])>0,"",
IF(ISNUMBER(FIND("beverage",[@[Food taken]])),1,0)+
IF(ISNUMBER(FIND("tea",[@[Food taken]])),1,0)+
IF(ISNUMBER(FIND("coffee",[@[Food taken]])),1,0)+
IF(ISNUMBER(FIND("milo",[@[Food taken]])),1,0)+
IF(ISNUMBER(FIND("ovaltine",[@[Food taken]])),1,0)
)


It does work as a count, but if I have 2 coffees, it doesn't count them as two, but one.
For instance, if, in E4, I have:
Lamb, rice, coffee coffee milo
And L4 results in 2.

I had 2 coffees, and one milo, so I want a read of 3

Screen shot reads
Lamb, rice, coffee coffee, not Lamb, rice, coffee coffee milo



Counting words.png



So, anyone got a fix?

Note:
I do have a list:

Search
Cereal
Muesli
Confort food
Fish
Dates
Fruit
Meat
Poultry
Sweet
Vegetable
Banana


Category
Cereal
Cereal
Confort food
Fish
Fruit
Fruit
Meat
Poultry
Sweet
Vegetable
Fruit

but the formula to pull from the table seems broken:
(sorry I can't put the table up here, the add-in doesn't work for me)

=IFERROR(INDEX(MyCategory,1/(1/MAX(ISNUMBER(SEARCH(MySearch,[@[Food taken]] & "|" & [@Notes]))*ROW(MyCategory)))),[@[Food taken]])
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,215,022
Messages
6,122,726
Members
449,093
Latest member
Mnur

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top