|
Home > Formulas > Count > List Items Count Specific Items in Excel List
|

In an Excel list, how many cells are equal to "pen"? Or, how many cells have "pen" in their text, like "gel pen" or "pencil"?
In this short video, I show how to count those cells, by using the Excel COUNTIF function.
There are written steps below the video, and a full video transcript at the end of this page.
In Microsoft Excel, you can use the COUNTIF function to count the number of cells in a range that meet a single criterion.
Here is the COUNTIF function syntax:
COUNTIF(range, criteria)
The COUNTIF function has 2 required arguments:
range - the range of cells to check for criteriacriteria - the criteria to match, for a cell to be counted
It's important to know about the following COUNTIF function limitations, before you use this function in your Excel spreadsheet.
Tip: To avoid these problems, see my suggestions in the Down the Rabbit Holesection.
In Excel, sometimes you need to count specific items in a range of cells. For example, how many cell contain the word, Pen.
To count based on one criterion, you can use the Excel COUNTIF function.

Follow the steps below, to create a COUNTIF formula to count the pen orders only:
For a named table, the completed formula shows the table name (tblExact) and column name (Item):
For a worksheet list, the formula shows the cell reference:
In the screenshot below, the formula result is in cell D4

Instead of counting exact matches in an entire cell, you might want to count cells where specific text is anywhere in the cell
In the screen shot below, I highlighted all the cells that contain "pen"
Like the previous example, I want to count the "Pen" orders.
However, this time, the formula will have asterisk (*) wildcard characters before and after the text string. -- "*Pen*"
The asterisk (*) wildcard represents unknown characters:
As a result, all the Pen, Gel Pen, and Pencil orders will be counted, because they contain the string "pen".
Follow the steps below, to create a COUNTIF formula to count all orders that are a partial match (or exact match) for "Pen":
For a named table, the completed formula shows the table and column names:
and for a worksheet list, the formula shows the cell reference:
In the screenshot below, the formula result is in cell D4

To make your formulas more flexible, and easier to maintain, you can type the criteria text that you want to count in an Excel worksheet cell.
Then, in the formula, refer to the cell where you typed the criteria text.
For example, here is the formula to match a specific item, with a reference to cell E7, where the criteria text, "pen", was typed.

You can use a cell reference with wildcard characters too.
Use the & (ampersand) operator to join the wildcard characters to the cell reference.

In this section, you'll find related Excel tips, shortcuts, skills, and details. These things are nice to know, but not essential, so you can skip this section, and get back to work. Or dive in, for some extra Excel fun and knowledge!
--b) False Duplicates With COUNTIF
The COUNTIF function can find specific letters or numbers in a text string. However, COUNTIF cannot find a specific number within a real number.
In the screen shot below, there are 4 items in the list that contain a "1". The COUNTIF formula in cell A9 gives an incorrect result of 3. It does not count the "1" in cell A2, because that cell contains a real number, not a text string.

Although the COUNTIF function can't count specific numbers within real numbers, the FIND or SEARCH function will locate them.
In the screen shot below, the following formulas are used in columns C, D and E, to look for a "1".
The ISNUMBER function returns True or False, and the two minus signs (double unary) convert True to 1 and False to 0 (zero).
The FIND and SEARCH formulas found all 4 items that contain a "1". The COUNTIF formula only found 3 items.

Instead of checking each row individually, use the SUMPRODUCT function with FIND or SEARCH, to get the total count for the list.
In this example, the formulas give a count of cells that contain a 1. The result is 4 in both cases.

In the next example, the formulas give a count of cells that contain "a". FIND only counts the lower-case "a" (1), and SEARCH counts both the upper-case "A", and lower-case "a" (2).

Be careful when using COUNTIF, because it matches numbers, with text that looks like numbers, and that could result in false counts.
For example, if you have a text entry -- "00123" -- it would be counted as a duplicate for the number -- 123.
=COUNTIF($B$2:$B$10,B2))>1
If your data could contain entries like that, use SUMPRODUCT, instead of COUNTIF.
=SUMPRODUCT(--($B$2:$B$10=B2))>1

Here is the transcript of the video above - Count Specific Items in Excel List.
__________
VIDEO TRANSCRIPT
In Excel, we have a list of sales orders and we would like to count how many orders there was a pen in the order. my list is from A1 to A10, and I'd like to count pen in that list.
to do that, I can use the COUNTIF function. in this cell I start with an equal sign and type COUNTIF, and an open bracket.
The first argument is which range I would like it to check.
I'm going to select A1 to A10.
I'll type a comma, to end that argument.
The next argument is the criteria. What exactly do I want it to count?
I'm looking for a text string, so in double quotes, I type a double quote and then pen and a closing quote and a closing bracket.
When I press Enter, it found 4 pen items in that list.
So 1, 2, 3, 4, it found all 4 of our pen items.
If we have on another worksheet, the same list. Here I've got pen, pencil, gel pen.
Maybe I'd like to find anything that has pen as part of the item name.
So not exactly pen, I don't want to count just the pens, but I'd like to include the gel pen and even a pencil.
Here, again, I'll use COUNTIF.
It's going to look for anything that contains the letters, P-E-N in a string.
And when I press Enter we get 6. So one, two, three, four, five, six.
It found anything that contained that string of characters, P-E-N and the case didn't matter.
Don't miss my monthly Excel newsletter! You'll get quick tips, article links, and a bit of fun. Add your email, and click Sign Up.
Next, when you get my reply, click the Confirm button. I add this step to protect you from spam!
Count Criteria in Other Column
Count Cells With Specific Text
Last updated: March 16, 2025 3:08 PM