# Counting Unique "Items"

#### gdseric

##### New Member
Need help! I have struggled with this for two days! I know it's right in front of me, but...

If I wanted to count the unique occurrences of items in a range (in Excel, obviously), how do I do it? For example, I have 516 rows of data in a worksheet (all participant/student activity related)...approximately 120 different students comprising 516 different activities. I can count the number of activities, no sweat, and can even categorize them by activity code, but how do I count the number of unique participants (with unique social security numbers) in the worksheet? 516 social security numbers in a list, but only about 120 students.

I am trying hard not to breach confidentiality, hence the vague question!

### Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

#### zzydhf

##### Board Regular
Have you tried a pivot table?

##### MrExcel MVP
On 2002-09-18 11:35, gdseric wrote:
Need help! I have struggled with this for two days! I know it's right in front of me, but...

If I wanted to count the unique occurrences of items in a range (in Excel, obviously), how do I do it? For example, I have 516 rows of data in a worksheet (all participant/student activity related)...approximately 120 different students comprising 516 different activities. I can count the number of activities, no sweat, and can even categorize them by activity code, but how do I count the number of unique participants (with unique social security numbers) in the worksheet? 516 social security numbers in a list, but only about 120 students.

I am trying hard not to breach confidentiality, hence the vague question!

Let A2:A520 house the SSNs.

Use one of:

=SUM(IF(LEN(A2:A520),1/COUNTIF(A2:A520,A2:A520)))

which you need to array enter using control+shift+enter (not just enter).

=COUNTDIFF(A2:A520)

which you enter normally.

http://longre.free.fr/english/index.html

#### gdseric

##### New Member
That did it, Aladin! I knew it was something simple. Thanks for the referral on the add-in. Didn't have that one! Eric

#### Mark W.

##### MrExcel MVP

Here's how it's done using a PivotTable...
Book3
ABCDEFGHI
1StudentActivityUniqueSumofUniqueTotal
2641-43-7466LMN0.333333Total5
3148-06-7463LMN0.333333
4641-43-7466XYZ0.333333
5531-32-6817XYZ0.5
6760-75-1566ABC0.5
7760-75-1566DEF0.5
8641-43-7466ABC0.333333
9547-55-7058LMN0.333333
10547-55-7058XYZ0.333333
11148-06-7463ABC0.333333
12531-32-6817ABC0.5
13148-06-7463DEF0.333333
14547-55-7058ABC0.333333
15
16
Sheet1

#### Chris Davison

##### MrExcel MVP

is the LEN thrown in to prevent any DIV/0 error if there's a blank in the range ?

ta
Chris

##### MrExcel MVP
On 2002-09-18 12:17, Chris Davison wrote:

is the LEN thrown in to prevent any DIV/0 error if there's a blank in the range ?

ta
Chris

Yes.

Replies
2
Views
193
Replies
3
Views
266
Replies
1
Views
453
Replies
31
Views
755
Replies
3
Views
177

1,148,182
Messages
5,745,210
Members
423,933
Latest member
ankushmukherjee

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back