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


Changing Error Checking Rules

Excel can check the data and formulas in your worksheet to see if it detects any errors. The rules used for this checking ...

Discover More

Unhiding Multiple Worksheets

You can hide a bunch of worksheets at the same time, but Excel makes it impossible to unhide a bunch at once. You can, ...

Discover More

Positioning Headers and Footers

If your workbook is destined for the printed page, you need to be concerned with the layout of that page. Excel allows ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (menu)

Viewing Formula Results

When editing information in a cell, you may need to know the result of a portion of your formula. The shortcut described ...

Discover More

Maintaining Text Formatting in a Lookup

Want to maintain the formatting used in one cell when you use formulas to reference that text in another cell? The answer ...

Discover More

Deriving Monthly Median Values

When processing huge amounts of data, it can be a challenge to figure out how to derive the aggregate values you need. ...

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 6 + 6?

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.