Hi dear forum users,
I am trying to find and motify a useful code to count unique row in the excel, here is the code:
#
Public Function CountUnique(rng As Range) As Long
Dim dict As Scripting.Dictionary
Dim cell As Range
Set dict = New Scripting.Dictionary
For Each cell In rng.Cells
If Not dict.Exists(cell.Value) Then
dict.Add cell.Value, 0
End If
Next
CountUnique = dict.count
End Function
#
However, it shows "Identifier under cursor is not recognized" for the first row of the code "Public Function CountUnique(rng As Range) As Long".
Anyone know why this happened and how to solve this? Thank you in advance for any help and suggestions.
I am trying to find and motify a useful code to count unique row in the excel, here is the code:
#
Public Function CountUnique(rng As Range) As Long
Dim dict As Scripting.Dictionary
Dim cell As Range
Set dict = New Scripting.Dictionary
For Each cell In rng.Cells
If Not dict.Exists(cell.Value) Then
dict.Add cell.Value, 0
End If
Next
CountUnique = dict.count
End Function
#
However, it shows "Identifier under cursor is not recognized" for the first row of the code "Public Function CountUnique(rng As Range) As Long".
Anyone know why this happened and how to solve this? Thank you in advance for any help and suggestions.