Count number of unique codes in a column

rob51852

Board Regular
Joined
Jun 27, 2016
Messages
190
Office Version
  1. 2016
Platform
  1. Windows
Hi, I have a spreadsheet which contains a list of 70,000 numeric codes in column B. Some of the codes are duplicated multiple times.

Is there a formula that will count the number of unique codes?

Thanks
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Hi,

You can use following formula

=SUMPRODUCT(1/COUNTIF(yourRange,yourRange))

Hope this will help
 
Upvote 0
Hi,

You can use following formula

=SUMPRODUCT(1/COUNTIF(yourRange,yourRange))

Hope this will help

Hi James,

Thanks. The formula just returns a 0... Have I transposed it wrong:

=SUMPRODUCT(1/COUNTIF(D2:D61932,D2:D61932))
 
Upvote 0
Hi,

Apparently 70'000 records is too much for Excel to swallow ...

Would suggest to Insert a Pivot Table ... much safer ...
 
Upvote 0
Hi,

Apparently 70'000 records is too much for Excel to swallow ...

Would suggest to Insert a Pivot Table ... much safer ...

Thanks. Just came back to my PC and it's done it: 2152

Thanks again
 
Upvote 0
Assuming you have headers in row 1, try this macro:
Code:
Sub CountUniques()
    Application.ScreenUpdating = False
    Dim LastRow As Long, rowCount As Long
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Range("B1:B" & LastRow).AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Range("B1:B" & LastRow), Unique:=True
    rowCount = [subtotal(103,B:B)] - 1
    MsgBox ("There are " & rowCount & " unique values.")
    Range("B1").AutoFilter
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,537
Messages
6,114,216
Members
448,554
Latest member
Gleisner2

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