Unique record count

Pizzio

Active Member
Joined
Apr 28, 2005
Messages
275
I'm looking for a formula that will count only the unique numbers on a sheet.

Example:
Column A has the first five rows that show 86, the sixth row shows 88.

Expectation:
Count of 2

Any ideas?
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
You can use frequency, obviously set the range to your needs


=SUM(IF(FREQUENCY(A1:A10,A1:A10)>0,1))
 
Last edited:
Upvote 0
If you can make use of a VBA solution, here is a UDF (user defined function) that will work with any range you specify (even if multiple rows and multiple columns) whether those cells contain numbers or text...
Code:
Function UniqueCount(Rng As Range) As Long
  Dim Cell As Range
  With CreateObject("Scripting.Dictionary")
    For Each Cell In Rng
      If Len(Cell.Value) Then .Item(Cell.Value) = 1
    Next
    UniqueCount = .Count
  End With
End Function

HOW TO INSTALL UDFs
------------------------------------
If you are new to UDFs, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. You can now use UniqueCount just like it was a built-in Excel function. For example,

=UniqueCount(A1:D9)

If you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.
 
Last edited:
Upvote 0
Pizzio,

Try the following.

In B1 enter the following formula:

=SUM(IF(FREQUENCY(A1:A6,A1:A6)>0,1))

B1 will display 2.
 
Upvote 0
Is there a way to add criteria to the formula?

Example:
Column A has the first five rows that show 86, the sixth row shows 88.

Criteria:
= 86

Expectation:
Count of 1
 
Upvote 0
Is there a way to add criteria to the formula?

Example:
Column A has the first five rows that show 86, the sixth row shows 88.

Criteria:
= 86

Expectation:
Count of 1

Not really a distinct/unique count, but the following should do...

=ISNUMBER(MATCH(86,A:A,0))+0
 
Upvote 0
Pizzio,

Try the following.

In B1 enter the following formula:

=SUM(IF(FREQUENCY(A1:A6,A1:A6)>1,1))

B1 will display 1.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,327
Members
452,635
Latest member
laura12345

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top