How to Count Distinct Values Using VBA
There is no in-built Function in Excel to Count the distinct values from the range. But with the help of VBA, we can make our function count the distinct Values in Excel.
Follow the steps to Count distinct values using VBA:
Step 1: Open the VBA
Select the Developer Tab in the ribbon then select Visual Basic, Now click on Insert and go to the module.
Step 2: Now write the Below code on the VBA screen
Step 3: This function will help you to create a new function in Excel COUNT DISTINCT VALUES which can be used just like other functions in Excel.
You can use the above VBA code to create a new function to count distinct values in Excel.
Also Read: Countif Function in Excel
How to Count Unique Values in Excel? 5 Easy Ways
Count Unique values in Excel is a feature that can help you to find the values that occur only once in the huge list of Excel. We often need to report the Unique number of customers purchased, the number of products in our stock, List of regions our business covered.
In this article, we explain how to count unique values in an Excel column.
Before moving ahead you should know the difference between unique values and distinct values.
- Unique Values: These are the values that occur only once. Unique Values from the list {1,2,3,1,4,2,7,5,7} are {3,4,5}.
- Distinct Values: These are the Values that are different. Distinct values from the list are {1,2,3,1,4,2,7,5,7} are {1,2,3,4,5,7}.