Quick, clean, and to the point

Count keywords cell contains

Excel formula: Count keywords cell contains
Generic formula 

To count the number of specific words or keywords that appear in a given cell, you can use a formula based on the SEARCH, ISNUMBER, and SUMPRODUCT functions. In the example shown, the formula in C5 is:


where "keywords" is the named range E5:E9.


Note: if a keyword appears more than once in a given cell, it will only be counted once. In other words, the formula only counts instances of different keywords.

The core of this formula is the ISNUMBER + SEARCH approach to finding text in a cell, which is explained in more detail here. In this case, we are looking in each cell for all words in the named range "keywords" (E5:E9). We do this by passing the range into SEARCH as the find_text argument. Because we pass in an array of 5 items:


we get an array of 5 items back as a result:


Numbers correspond to matches, and the #VALUE! error means no match was found. In this case, because we don't care where the text was found in the cell, we use ISNUMBER to convert the array into TRUE and FALSE values:


And the double negative (--) to change these into 1s and zeros:


The SUMPRODUCT function then simply returns the sum of the array, 2 in this case.

Handling empty keywords

If the keyword range contains empty cells, the formula won't work correctly, because the SEARCH function returns zero when looking for an empty string (""). To filter any empty cells in the keyword range, you can use the variation below:


Note: this version an array formula and must be entered with control + shift + enter.

Dave Bruns

Excel Formula Training

Formulas are the key to getting things done in Excel. In this accelerated training, you'll learn how to use formulas to manipulate text, work with dates and times, lookup values with VLOOKUP and INDEX & MATCH, count and sum with criteria, dynamically rank values, and create dynamic ranges. You'll also learn how to troubleshoot, trace errors, and fix problems. Instant access. See details here.

Download 100+ Important Excel Functions

Get over 100 Excel Functions you should know in one handy PDF.