Home > Formulas > Count > List Items

Count Specific Items in Excel List

Debra Dalgleish - Contextures

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"? Use the COUNTIF function to get the answers! I show how, in a short video, and written steps.

count specific items in Excel list

Video: Count Specific Items in 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.

Get the Sample File

  • COUNTIF Examples: To follow along with the COUNTIF examples, click the link, to download the Count Specific Items sample workbook. The zipped file is in xlsx file format, and does not contain any macros.

Excel COUNTIF Function

In Microsoft Excel, you can use the COUNTIF function to count the number of cells in a range that meet a single criterion.

COUNTIF Arguments

Here is the COUNTIF function syntax:

  • COUNTIF(range, criteria)

COUNTIF function arguments

The COUNTIF function has 2 required arguments:

  1. range - the range of cells to check for criteria
  2. criteria - the criteria to match, for a cell to be counted
    • type it in the formula, or refer to a cell that contains the criteria

⚠ COUNTIF Warnings

It's important to know about the following COUNTIF function limitations, before you use this function in your Excel spreadsheet.

  • Numbers In Numbers: The COUNTIF function can't count numbers within numbers. For example, it can't find '123' within '91236'
  • Text Numbers: If the range of cells has a mixture of text and numbers, you might get incorrect counts. For example, COUNTIF matches text numbers, like "00123", with real numbers, like 123.

Tip: To avoid these problems, see my suggestions in the Down the Rabbit Holesection.

Count Exact Match Items

In Excel, sometimes you need to count specific items in a range of cells. For example, how many cell contain the word, Pen.

  • In the screen shot below, there is a list of items that were ordered, and the quantity for each item.
  • Item names are in cells A2:A10
  • I want to count how many times a Pen was ordered.

To count based on one criterion, you can use the Excel COUNTIF function.

count specific items in Excel list

Create COUNTIF Formula

Follow the steps below, to create a COUNTIF formula to count the pen orders only:

  1. Select a cell for your formula - cell D4 in this example)
  2. Type an equal sign (=) to start the formula
  3. Type:   COUNTIF(
  4. Select the range of cells where the items are listed - cells A2:A10 in this example
    • NOTE: If your list is in a named Excel table, the formula will show the table name and column name -- =COUNTIF(tblExact[Item]
  5. Type a comma, to separate the arguments
  6. Type the value that you want to match. In this example, the value is text, it's typed inside double quote marks:   "Pen"
    • Note: You can use upper or lower case for the criteria
      • COUNTIF is not case sensitive
  7. Type a closing bracket, and press Enter

COUNTIF Formula Result

For a named table, the completed formula shows the table name (tblExact) and column name (Item):

  • =COUNTIF(tblExact[Item], "Pen")

For a worksheet list, the formula shows the cell reference:

  • =COUNTIF(A2:A10, "Pen")

In the screenshot below, the formula result is in cell D4

  • There are 4 orders with an exact match for the "pen" criterion.

count specific items in Excel list

Count Partial Match Items

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"

  • Exact match: match the entire cell value,
    • OR
  • Partial Match: matching any part of the cell value

count specific items anywhere in a cell

Wildcard Characters in Formula

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:

  • any number of unknown characters
    • OR
  • no unknown characters

As a result, all the Pen, Gel Pen, and Pencil orders will be counted, because they contain the string "pen".

Create Partial Match COUNTIF Formula

Follow the steps below, to create a COUNTIF formula to count all orders that are a partial match (or exact match) for "Pen":

  1. First, select a cell for your formula - cell D4 in this example)
  2. Type an equal sign (=) to start the formula
  3. Type:   COUNTIF(
  4. Select the cells where the items are listed - cells A2:A10 in this example
    • NOTE: If your list is in a named Excel table, the formula will show the table name and column name -- =COUNTIF(tblExact[Item]
  5. Type a comma, to separate the arguments
  6. Inside double quotes, type the value that you want to match, with asterisk (*) wildcard character before and after the text:   "*Pen*"
    • Note: You can use upper case or lower case -- COUNTIF is not case sensitive
  7. Type a closing bracket, and press Enter

Completed Formula With Wildcards

For a named table, the completed formula shows the table and column names:

  • =COUNTIF(tblExact[Item], "*Pen*")

and for a worksheet list, the formula shows the cell reference:

  • =COUNTIF(A2:A10, "*Pen*")

In the screenshot below, the formula result is in cell D4

  • There are 6 orders where the cell contains the text "pen" - either an exact match or a partial match.

count specific items anywhere in a cell

Use Cell References

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.

  • =COUNTIF(tblExact[Item], E7)

use cell reference to match exact text

Use Wildcards in Formula

You can use a cell reference with wildcard characters too.

Use the & (ampersand) operator to join the wildcard characters to the cell reference.

  • =COUNTIF(tblWild[Item], "*" & E7 & "*")

use cell reference to match exact text

🐰 Down the Rabbit Hole 🐰

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!

--a) Count Numbers in Numbers

--b) False Duplicates With COUNTIF

a) Count Numbers in Numbers

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.

Use FIND or SEARCH

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).

  • C2: =COUNTIF(A2,"*1*")
  • D2: =--ISNUMBER(FIND(1,A2))
  • E2: =--ISNUMBER(SEARCH(1,A2))

The FIND and SEARCH formulas found all 4 items that contain a "1". The COUNTIF formula only found 3 items.

Use SUMPRODUCT with FIND or SEARCH

Instead of checking each row individually, use the SUMPRODUCT function with FIND or SEARCH, to get the total count for the list.

  • Use FIND to count numbers, or case-sensitive letters
  • Use SEARCH to count numbers, or upper and lower case letters (not case-sensitive)

Example 1: Numbers

In this example, the formulas give a count of cells that contain a 1. The result is 4 in both cases.

  • A9:    =SUMPRODUCT(--ISNUMBER(FIND(1,$A$2:$A$7)))
  • A10:  =SUMPRODUCT(--ISNUMBER(SEARCH(1,$A$2:$A$7)))

Example 2: Letters

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).

  • A9:   =SUMPRODUCT(--ISNUMBER(FIND("a",$A$2:$A$7)))
  • A10: =SUMPRODUCT(--ISNUMBER(SEARCH("a",$A$2:$A$7)))

False Duplicates With COUNTIF

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

false duplicates with COUNTIF

Video Transcript - Count Specific Items

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.

First Argument

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.

Second 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.

Item Name Contains "Pen"

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.

Start COUNTIF Formula

Here, again, I'll use COUNTIF.

  • I'll start with an equal sign, COUNTIF, and an open bracket, and then the range is A1 to A10, type a comma.
  • For this, I want it to include anything that has pen in it.
  • I'll type my double quote mark and then an asterisk.
  • On my keyboard that was Shift 8.
  • That's a wild card character that represents any number of characters or no characters.
  • Then the text I'm looking for. I can use upper or lowercase there
  • Another asterisk, another double quote and a closing bracket.

It's going to look for anything that contains the letters, P-E-N in a string.

  • There can be anything before that or nothing.
  • And there can be anything after those three letters or nothing.

Formula Result

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.

Get the Excel Files ✅

Get Monthly Excel Tips!

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!

More Function Tutorials

Compare 2 Lists

COUNT / COUNTIF

Count Criteria in Other Column

Count Cells With Specific Text

Count Specific Items in Cell

AVERAGE

SUM / SUMIF

Subtotal Feature

 

 

Last updated: March 16, 2025 3:08 PM