Excel formula for Beginners – How to Count cells that contain string in Excel

 

(Excel examples for Beginners)

In this end-to-end excel example, you will learn – How to Count cells that contain string in Excel.

 

How to Count cells that contain string in Excel

 

Generic formula 
=SUMPRODUCT(--((ISNUMBER(FIND("abc",rng)) +  ISNUMBER(FIND("def",rng)))>0))
Explanation

To count cells that contain either one value or another, you an either use a helper column then tally up the count, or a more complex single cell formula.

Background

When you count cells with “OR” criteria, you need to be careful not to double count. For example, if you are counting cells that contain “abc” or “def”, you can’t just add together two COUNTIF functions, because you may double count cells that contain both “abc” and “def”.

Single cell solution

For a single cell solution, you can use SUMPRODUCT with an ISNUMBER + FIND combo. The formula in cell F5 is:

=SUMPRODUCT(--((ISNUMBER(FIND("abc",B5:B11)) +  ISNUMBER(FIND("def",B5:B11)))>0))

This formula is based on the formula here that locates text inside of a cell:

ISNUMBER(FIND("abc",B5:B11)

When given a range of cells, this snippet will return an array of TRUE/FALSE values, one value for each cell the range. Since we are using this twice (once for “abc” and once for “def”), we’ll get two arrays.

Next, we add these arrays together (with +), which creates a new single array of numbers. Each number in this array is the result of adding the TRUE and FALSE values in the original two arrays together. In the example shown, the array looks like this:

{2;0;2;0;1;0;2}

We need to add these numbers up, but we don’t want to double count. So we need to make sure any value greater than zero is just counted once. To do that, we force all values to TRUE or FALSE with “>0”, then force to 1/0 with the double-negative (–).

Finally, SUMPRODUCT adds these numbers up.

 

Personal Career & Learning Guide for Data Analyst, Data Engineer and Data Scientist

Applied Machine Learning & Data Science Projects and Coding Recipes for Beginners

A list of FREE programming examples together with eTutorials & eBooks @ SETScholars

95% Discount on “Projects & Recipes, tutorials, ebooks”

Projects and Coding Recipes, eTutorials and eBooks: The best All-in-One resources for Data Analyst, Data Scientist, Machine Learning Engineer and Software Developer

Topics included: Classification, Clustering, Regression, Forecasting, Algorithms, Data Structures, Data Analytics & Data Science, Deep Learning, Machine Learning, Programming Languages and Software Tools & Packages.
(Discount is valid for limited time only)

Disclaimer: The information and code presented within this recipe/tutorial is only for educational and coaching purposes for beginners and developers. Anyone can practice and apply the recipe/tutorial presented here, but the reader is taking full responsibility for his/her actions. The author (content curator) of this recipe (code / program) has made every effort to ensure the accuracy of the information was correct at time of publication. The author (content curator) does not assume and hereby disclaims any liability to any party for any loss, damage, or disruption caused by errors or omissions, whether such errors or omissions result from accident, negligence, or any other cause. The information presented here could also be found in public knowledge domains.

Learn by Coding: v-Tutorials on Applied Machine Learning and Data Science for Beginners

Please do not waste your valuable time by watching videos, rather use end-to-end (Python and R) recipes from Professional Data Scientists to practice coding, and land the most demandable jobs in the fields of Predictive analytics & AI (Machine Learning and Data Science).

The objective is to guide the developers & analysts to “Learn how to Code” for Applied AI using end-to-end coding solutions, and unlock the world of opportunities!

 

Excel formula for Beginners – How to Count cells that contain text in Excel

Excel formula for Beginners – How to Count cells that contain specific text in Excel

Python Example – Write a Python program to convert a list of multiple integers into a single integer