Count Unique Values in Excel Using COUNTIF Function
※ Download: Excel count unique
The data in column G:G is seven character numeric and is on a different worksheet within the same workbook. In this tutorial, you will learn how to count unique values in Excel with formulas, and how to get an automatic count of distinct values in a pivot table. The Catch: This formula woks nicely on a continuous set of values in a range, however if your values contain empty cells, then this formula fails.
Hello, Karolis, Would it be possible for you to send us a small sample workbook with your source data and the result you want to get? O'Brien and Obrien both become OBRIEN.
Count unique values among duplicates - Read these articles for more details on or.
If you want to find the count of unique values in a single cell without extracting a separate list, then you can use a combination of SUM and COUNIF. In this method, you just have to refer to the list of the values and the formula will return the number of unique values. This is an array formula, so you need to enter it as an array, and while entering it use. And the formula is: To understand this formula you need to break it down into three parts and just remember that we have entered this formula as an array and there are total 16 values in this list, not unique but total. In the first part, you have used COUNIF to count the number of each value from 16 and here COUNTIF returns values like below. And, in the third part, you have simply used SUM function to sum all those values and you have a count of unique values. This formula is quite powerful and it can help you to get the count in a single cell. Function CountUnique ListRange As Range As Integer Dim CellValue As Variant Dim UniqueValues As New Collection Application. Volatile On Error Resume Next For Each CellValue In ListRange UniqueValues. Count End Function Counting unique values can be useful for you while working with large datasets. Like the name list which you have used here had duplicate names and after calculating unique numbers, we get that there are 10 unique names in the list. Well, all the methods which you have learned here are useful in different situations and you can use anyone from these which you think is a perfect fit for you.
For example, after filtering out the unique names, we get the following list of duplicate names: Peter, Maria, Peter, Rob, Maria. I also tried using the Data Model and distinct count. Click Data tab in the ribbon, and then click Advanced command, see screenshot: 2. If your data contains mixed case I would also recommend reformatting everything to the same case format. I copied and pasted my dataset into a different sheet to verify it and it's worked for me. I have a row of 20 cells.