Excel.Tips.Net ExcelTips (Menu Interface)

Getting a Count of Unique Names

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.

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.

Related Tips:

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!


Leave your own comment:

  Notify me about new comments ONLY FOR THIS TIP
Notify me about new comments ANYWHERE ON THIS SITE
Hide my email address
*What is 5+3 (To prevent automated submissions and spam.)
           Commenting Terms

Comments for this tip:

Shreyas MJ    03 May 2016, 07:22

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.

Ramesh.P.S    26 Sep 2015, 06:39
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.....
TheQuaker    20 Feb 2015, 18:12

Returns error on blank cells; may or may not be desirable.
Steven Marzuola    11 Jul 2014, 03:26
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?
Kuttan    22 Jun 2014, 03:18
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
Michael (micky) Avidan    05 Jul 2013, 10:11
@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
Scott Renz    01 Jul 2013, 11:23
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.
Michael (micky) Avidan    29 Jun 2013, 10:56
@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
Michael (micky) Avidan    29 Jun 2013, 10:46
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
Steve    29 Jun 2013, 09:22
A pivot table would do this quickly ... point and click, no formula needed.
Esskay    29 Jun 2013, 07:36
Or you could just throw the data into a pivot table.
Roan    29 Jun 2013, 05:48
My apologies, it should be

Roan    29 Jun 2013, 05:42
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).
Michael (micky) Avidan    29 Jun 2013, 05:37
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

Our Company

Sharon Parq Associates, Inc.

About Tips.Net

Contact Us


Advertise with Us

Our Privacy Policy

Our Sites


Beauty and Style




DriveTips (Google Drive)

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2016)



Home Improvement

Money and Finances


Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2016)

Our Products

Helpful E-books

Newsletter Archives


Excel Products

Word Products

Our Authors

Author Index

Write for Tips.Net

Copyright © 2017 Sharon Parq Associates, Inc.