jebenexcel
Board Regular
- Joined
- Mar 16, 2018
- Messages
- 59
Hi,
I found a user defined function that counts unique entries in a range. Why does it output 0 for me?
I found a user defined function that counts unique entries in a range. Why does it output 0 for me?
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
Last edited: