Large Data set. Unique values Formula

ItalianPlatinum

Well-known Member
Joined
Mar 23, 2017
Messages
793
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hello - I have a dataset where there will be 39 unique results, but they could repeat up to 100k times on the excel. I need a formula to strip me out of all that data and just give me how many unique results are there. I found the below formula to work but it is WAY TOO SLOW to calculate. is there a faster way to get what i need? the -7 is because above the data i have 7 fields of unrelated data. was hoping a formula did not want to go the VBA or remove duplicates route.

=SUMPRODUCT((A:A <> "")/COUNTIF(A:A,A:A & ""))-7

Thanks in advance
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
You can use countif by adding a helper column

Book1
BC
4INVOICECount if
5INA20090041
6INA20090061
7INA20090042
8INA20090043
9INA20090051
10INA20090062
11INA20090071
12INA20090081
13INA20090091
Sheet2
Cell Formulas
RangeFormula
C5:C13C5=COUNTIF($B$4:B5,B5)


If the value is greater than 1 then it is duplicate then you can use a Pivot or Filter Option also


Also, You can draw a Pivot table to find the Unique Values
 
Upvote 0
You can use countif by adding a helper column

Book1
BC
4INVOICECount if
5INA20090041
6INA20090061
7INA20090042
8INA20090043
9INA20090051
10INA20090062
11INA20090071
12INA20090081
13INA20090091
Sheet2
Cell Formulas
RangeFormula
C5:C13C5=COUNTIF($B$4:B5,B5)


If the value is greater than 1 then it is duplicate then you can use a Pivot or Filter Option also


Also, You can draw a Pivot table to find the Unique Values
Trying to go away from a table cause te unique values could change overtime. so making it dummy proof or trying to
 
Upvote 0
Try limiting the range of the formula, you should avoid using entire columns when using arrays.
=SUMPRODUCT((A5:A100000 <> "")/COUNTIF(A5:A100000,A5:A100000 & ""))
 
Upvote 0
Try limiting the range of the formula, you should avoid using entire columns when using arrays.
=SUMPRODUCT((A5:A100000 <> "")/COUNTIF(A5:A100000,A5:A100000 & ""))
getting this error message
#NAME?
 
Upvote 0
I just used the formula you supplied & limited the ranges.
So you would only get that error if you mistyped the formula, or you have a #NAME? error somewhere in col A.
 
Upvote 0
I just used the formula you supplied & limited the ranges.
So you would only get that error if you mistyped the formula, or you have a #NAME? error somewhere in col A.
odd because if i do A:A it works but if i limit it then it doesn't produce results. I can confirm #NAME? doesnt exist anywhere in column A
 
Upvote 0
I stumbled on this and so far it looks to be running quickly and yielding the results I need

=CountUniqueValues(A:A)-7

Public Function CountUniqueValues(rng As Variant) As Variant
Dim Test As New Collection
Dim Value As Variant
rng = rng.Value
On Error Resume Next
For Each Value In rng
If Len(Value) > 0 Then Test.Add Value, CStr(Value)
Next Value
On Error GoTo 0
CountUniqueValues = Test.Count
End Function
 
Upvote 0
Glad you sorted it & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,967
Messages
6,122,503
Members
449,090
Latest member
RandomExceller01

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