# 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:

```=SUM(1/COUNTIF(B2:B50,B2:B50))
```

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:

```=SUM(IF(FREQUENCY(IF(LEN(B2:B50)>0,MATCH(B2:B50,B1:B50,0),
""),IF(LEN(B2:B50)>0,MATCH(B2:B50,B2:B50,0),""))>0,1))
```

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

```=IF(B2<>B3,1,0)
```

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.

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

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

Shreyas MJ    03 May 2016, 07:22
Hello,

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.

Thanks
Shreyas
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
=(COUNTIF(\$B\$2:\$B\$8,B2)/COUNTIF(\$B\$2:\$B\$8,B2))-SUMIF(\$B\$1:B1,B2,\$C\$1:C1)

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
ISRAEL
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
ISRAEL
Michael (micky) Avidan    29 Jun 2013, 10:46
@Roan,
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
ISRAEL
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

=IF(COUNTIF(\$B\$1:B2,B2)>1,0,1)
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

=IF(COUNTIF(\$B\$1:B1,B2)>1,0,1)

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:

=SUM((B2:B50<>"")/(COUNTIF(B2:B50,B2:B50)+(B2:B50="")))

Michael Avidan
“Microsoft®” MVP – Excel
ISRAEL

# Our Company

Sharon Parq Associates, Inc.

# Our Sites

Tips.Net

Beauty and Style

Cars

Cleaning

Cooking

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2016)

Gardening

Health

Home Improvement

Money and Finances

Organizing

Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2016)

Excel Products

Word Products

# Our Authors

Author Index

Write for Tips.Net