Here is a VBA function that works for me.
You can use it as a worksheet function, referencing any range, eg “=CountUnique(N8:O9)”
It handles text and numeric values, and treats blank cells as one value
It does not require dealing with array functions.
It requires a reference to the Microsoft Scripting Library, for the dictionary object.
Public Function CountUnique(rng As Range) As Integer
Dim dict As Dictionary
Dim cell As Range
Set dict = New 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