How to count the occurrences of a number or text in a range in Excel

Support for Office 2003 has ended

Microsoft ended support for Office 2003 on April 8, 2014. This change has affected your software updates and security options. Learn what this means for you and how to stay protected.

Summary
This article explains how you can use worksheet functions in Microsoft Excel for Mac to count the number of occurrences of a specific number or text string in a range of cells on a worksheet. The "More Information" section of this article contains sample formulas that you can use to do this.
More information
In the cell that you want the result to appear in, enter the appropriateformula from the following examples.

How to Count the Occurrences of a Number

Use this formula
=SUM(IF(range=number,1,0))
where range is the range that you want to search, and number is the number that you want to count.

NOTE: This formula must be entered as an array formula. To enter an array formula, press CTRL+SHIFT+ENTER.

How to Count the Occurrences of a Text String

Method 1

Use this formula
=SUM(IF(range="text",1,0))
where range is the range that you want to search, and text is the text that you want to find (the text must be enclosed in quotation marks).

NOTE: The above formula must be entered as an array formula. To enter an array formula, press CTRL+SHIFT+ENTER.

Method 2

Use the COUNTIF() function to count the occurrences of a text string. Forexample, use the formula
=COUNTIF(range,"text")
where range is the range of cells that you are evaluating, and text is the text string that you want to count instances of (note that text must be enclosed in quotation marks).

Wildcard characters can be used within the COUNTIF function.

The asterisk character (*) represents more than one character. For example, to count all the cells in the range a1:a10 that contain an "x," you can use the following formula:
=COUNTIF(a1:a10,"*x*")
The question mark character (?) can also be used to represent one wildcardcharacter -- for example, to count all cells in the range whose secondcharacter is the letter, such as "ax" or "bx."
=COUNTIF(a1:a10,"?x*")
XL2002 XL2000 MacXLX Mac XLX XL2001 XL98 XL97 XL7 XL2003 XL2007 XL2010 kbhowto answer text string
Properties

Article ID: 214153 - Last Review: 09/23/2015 06:46:00 - Revision: 9.0

Microsoft Excel 2004 for Mac, Microsoft Excel X for Mac, Microsoft Excel 2001 for Mac, Microsoft Excel 98 for Macintosh, Microsoft Excel 2002 Standard Edition, Microsoft Excel 2000 Standard Edition, Microsoft Excel 97 Standard Edition, Microsoft Excel 95 Standard Edition, Microsoft Office Excel 2003, Microsoft Excel 2010, Microsoft Office Excel 2007, Excel 2016

  • dftsdahomeportal kbhowto KB214153
Feedback