Hindi-Tech :Count unique values in a range in excel using VBA Code

0 B R YADAV

Hindi-Tech : Count unique values in a range in excel using VBA Code



Press Alt + F11 key on the Excel, this will open the VBA window.
On the VBA Window, right-click over the ‘Microsoft Excel Objects’ > ‘Insert’ > ‘Module’.
=COUNTUNIQUE(A1:A10,FALSE/TRUE)

VBA CODE👇👇
[Function COUNTUNIQUE(DataRange As Range, CountBlanks As Boolean) As Integer
Dim CellContent As Variant
Dim UniqueValues As New Collection
Application.Volatile
On Error Resume Next
For Each CellContent In DataRange
If CountBlanks = True Or IsEmpty(CellContent) = False Then
UniqueValues.Add CellContent, CStr(CellContent)
End If
Next
COUNTUNIQUE = UniqueValues.Count
End Function]

[contact]


Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

#buttons=(Ok, Go it!) #days=(20)

Our website uses cookies to enhance your experience. Check Out
Ok, Go it!