Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Getting a Count of Unique Names.

Getting a Count of Unique Names

by Allen Wyatt
(last updated February 20, 2018)


John has a worksheet that he uses for registration of attendees at a conference. Column A has a list of each person attending, and column B has the company represented by each attendee. Each company can have multiple people attend. John can easily figure out how many individuals are coming to the conference; it is simply the number of rows in column A (minus any header rows). The more difficult task is to determine how many companies are going to be represented at the conference.

There are a couple of ways to determine the desired count. First, if there are no blank cells in column B, you can use an array formula (entered by Ctrl+Shift+Enter) such as the following:


If there are blanks in the range (B2:B50 in this case), then the array formula will return a #DIV/0! error. If that case, the array formula needs to be changed to the following:


If you prefer to not use an array formula, you can add regular formulas to column C to do the count. First, sort the table of data by the contents of column B. That way the data will be in company order. Then add a formula such as the following to cell C2 (assuming you have a header in row 1):


Copy the formula down through all the rest of the cells in column C, and then do a sum on the column. The sum represents the number of unique companies attending, since a 1 only appears in column C when the companies change.

Of course, if you need to find the names of all the companies represented at the conference, you can use Excel's filtering capabilities. Follow these steps:

  1. Sort the data by column B, the company names.
  2. Select all the cells containing data (including the header cell) in column B.
  3. Choose Filter from the Data menu, then choose Advanced Filter. Excel displays the Advanced Filter dialog box. (See Figure 1.)
  4. Figure 1. The Advanced Filter dialog box.

  5. Make sure the Copy to Another Location radio button is selected.
  6. Make sure the Unique Records Only check box is selected.
  7. With the insertion point in the Copy To box, click on a blank cell, such as E1. (This is where the list of companies will be copied to.)
  8. Click OK. Excel copies the unique company names from the original list to column E.

You now can easily see how many companies are being represented, along with who those companies are.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (3105) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Getting a Count of Unique Names.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...


Seeing Excel's Program Window

Have you ever opened Excel to find that the window you saw yesterday is not the same as it is today? Sometimes, for ...

Discover More

Word 2010 Styles and Templates (Table of Contents)

Styles are at the heart of Word's formatting power. Understanding how to use styles can greatly increase your ability to ...

Discover More

Picking a Group of Cells

Excel makes it easy to select a group of contiguous cells. However, it also makes it easy to select non-contiguous groups ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (menu)

Saving Common Formulas

It is not uncommon to reuse formulas in a variety of workbooks. If you develop some "gotta keep" formulas, here are some ...

Discover More

Adjusting Test Scores Proportionately

Teachers often grade on what is affectionately referred to as "the curve." The problem is, it can be a bit difficult to ...

Discover More

Determining If a Value is Out of Limits

Need to figure out if a value is outside of some arbitrary limit related to a different value? There are a number of ways ...

Discover More

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.


If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is one less than 3?

2016-05-03 07:22:07

Shreyas MJ


I have a invoice data for three years i want to do comparision for the uniques vendor names added month on month for a particular year and also would like to know what are the excisting vendors month on month.

Please let me know how can this be achieved.


2015-09-26 06:39:11


How can i count Absent,Present and half day value as '0','1'and '0.5' respectively in a single cell. for the preparation of Salary sheet from daily report.....

2015-02-20 18:12:10



Returns error on blank cells; may or may not be desirable.

2014-07-11 03:26:54

Steven Marzuola

I used the Sort in-place method, just to see something, and then deleted the values in those cells. Later I realized that some of the rows remained hidden. How can I unhide those rows?

2014-06-22 03:18:26


I have one sheet with a family details.
for example, employee, has 2 wife, three son and 3 daughter, can you please help me how to count

2013-07-05 10:11:49

Michael (micky) Avidan

@Scott Renz,
With all due respect - there are numerous solutions, that involves helper Rows/Columns/Sheets.

My "Moto" (and you may protest against it) is to use NO helper elements and keep formulas as simple as possible.

Michael Avidan
“Microsoft®” MVP – Excel

2013-07-01 11:23:03

Scott Renz

I would just copy the column of company names to a new sheet and click on "Remove Duplicates" in the "Data Tools" tab under "Data." Then it is just a simple count of the cells in the column with data.

2013-06-29 10:56:29

Michael (micky) Avidan

@Steve & Esskay,

As far as I remember the issue was presenting ONE(!) figure as the count of the UNIQUE values in a range.

With all due respect - a PT is not one of the common solutions for that task.

On answer requests the use of ONE cell (Only a SINGLE Cell) not a Helper column neither a PT.

I rest my case.

Michael Avidan
“Microsoft®” MVP – Excel

2013-06-29 10:46:29

Michael (micky) Avidan

I never heard someone offering a presentation of 49(!) formulas in 49 cells in order to count the Unique Values.
(Would you consider that as a decent suggestions if the range was B2:B634587 ?
Farther more - no one mentioned (at least I didn't) anything about the need to sort the list.
Above all that - try to "empty" some cells in the range and let me know if you consider "blanks as "unique" values (because your suggested procedure counts them as such!)

Michael Avidan
“Microsoft®” MVP – Excel

2013-06-29 09:22:33


A pivot table would do this quickly ... point and click, no formula needed.

2013-06-29 07:36:58


Or you could just throw the data into a pivot table.

2013-06-29 05:48:45


My apologies, it should be


2013-06-29 05:42:36


If you don't want to use an array formula and prefer not to sort the list first, then you can use


Drag it down to row 50 and count column B. For those who would like to know why it works: the crux is that as you drag the formula down, the countif range expands because the part after the colon does not have the $ signs (ie. not absolutely referenced).

2013-06-29 05:37:23

Michael (micky) Avidan

For avoiding he formula from referring to/counting empty cells - there is no need for such a "monster" Array formula.

Here is a much simpler/shorter one:


Michael Avidan
“Microsoft®” MVP – Excel

This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.